Description
RCN: Redundant nullcheck of mt which is known to be null
This method contains a redundant check of a known null value against the constant null.
做了無謂的nullcheck。
Solution
把它拿掉就好。
Example
Before:
InputStream inputStream = null; try { inputStream = new FileInputStream("temp.txt"); } catch( Exception e ){ if( inputStream != null ){ Cleaner.close(inputStream); } logger.error("", e); }
After:
InputStream inputStream = null; try { inputStream = new FileInputStream("temp.txt"); } catch( Exception e ){ logger.error("", e); }
上面範例的close理想中要把它放到finally中。
留言
張貼留言