Fix codeql java warning (#7280)

This commit is contained in:
Guoyu Wang 2021-04-08 11:08:12 -07:00 committed by GitHub
parent 0d49e53985
commit 4969431eba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 3 deletions

View file

@ -99,7 +99,7 @@ final class OnnxRuntime {
providers = initialiseProviders(ortApiHandle);
loaded = true;
} finally {
if (!isAndroid()) {
if (tempDirectory != null) {
cleanUp(tempDirectory.toFile());
}
}

View file

@ -19,7 +19,6 @@ import java.nio.ShortBuffer;
* returned as outputs.
*/
public class OnnxTensor implements OnnxValue {
static {
try {
OnnxRuntime.init();
@ -558,7 +557,6 @@ public class OnnxTensor implements OnnxValue {
OrtEnvironment env, OrtAllocator allocator, ByteBuffer data, long[] shape, OnnxJavaType type)
throws OrtException {
if ((!env.isClosed()) && (!allocator.isClosed())) {
int bufferSize = data.capacity();
return createTensor(type, allocator, data, shape);
} else {
throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator.");