Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

UF.NIO

UF (Use Freed) issues are reported when there is an attempt to use resources after they were released. The UF.NIO warning indicates an attempt to use a java.nio.* object after it was closed.

Example 1

15      public boolean checkMeta(ReadableByteChannel channel) {
16         final ByteBuffer b = ByteBuffer.allocate(8);
17         try {
18             final int i = channel.read(b);
19             if (i < 8) {
20                 return false;
21             }
22         } catch (IOException e) {
23             return false;
24         } finally {
25             try {
26                 channel.close();
27             } catch (IOException e) {
28                 // do nothing
29             }
30         }
31 
32         // Cast unsigned character constants prior to comparison
33         return (b.get(0) == (byte) 'm' && b.get(1) == (byte) 'y' &&
34                 b.get(2) == (byte) 'f' && b.get(3) == (byte) 'o' &&
35                 b.get(4) == (byte) 'r' && b.get(5) == (byte) 'm' &&
36                 b.get(6) == (byte) 'a' && b.get(7) == (byte) 't');
37     }
38 
39     public void printOut(final String path) throws IOException {
40         final ReadableByteChannel ch = new FileInputStream(path).getChannel();
41         if (checkMeta(ch)) {
42             try {
43                 final ByteBuffer b = ByteBuffer.allocate(1024);
44                 int i;
45                 while ((i = ch.read(b)) > 0) {
46                     print(b);
47                 }
48             } catch (IOException e) {
49                 e.printStackTrace();
50             }
51         }
52     }
53 
54     public void print(final ByteBuffer b) {
55         while (b.hasRemaining()) {
56             System.out.print(b);
57         }
58         b.clear();
59     }

UF.NIO is reported for the snippet on line 45: There is an attempt to read from the channel which is closed on line 26