-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Although this may not happen on desktop or laptop machine, directly using metamaplite in android produces w/system: a resource failed to call end(close)
. This error is basically caused by un-released fileinputstream
or fileoutputstream
. On android, the newly opened fileinputstream
or fileoutputstream
needs to be closed explicitly. In particular, this error comes from 2 sides when using metamaplite on android:
- from metamaplite:
For example, in Example.java and Example2.java, the newly createdFileReader
is not closed after usage, so they need to be explicitly closed as shown below:
FileReader fr = new FileReader("./config/metamaplite.properties");
myProperties.load(fr);
...
fr.close();
- from 3rd party library:
For example, in org.apache.opennlp, opennlp/tools/util/model/BaseModel.java(loadModel) and opennlp/tools/util/model/BaseModel.java(finishLoadingArtifacts),ZipInputStream zip
is not explicitly closed. This can be achieved by the following:
- In
loadModel
method:
final ZipInputStream zip = new ZipInputStream(in);
...
zip.close()
- In
finishLoadingArtifacts
ZipInputStream zip = new ZipInputStream((InputStream)in);
...
zip.close()
If more attention is paied, here I replaced the final ZipInputStream zip = new ZipInputStream(in);
with ZipInputStream zip = new ZipInputStream((InputStream)in);
. Yes, only in this way I can re-compile the the opennlp source code into a jar file in maven. If there is an alternative, please let me know.
Metadata
Metadata
Assignees
Labels
No labels