commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject commons-crypto git commit: Revert "CRYPTO-63: Add JNA binding (issue fix)"
Date Thu, 30 Jun 2016 06:46:18 GMT
Repository: commons-crypto
Updated Branches:
  refs/heads/master 88f3276bc -> ed48fad6c


Revert "CRYPTO-63: Add JNA binding (issue fix)"

This reverts commit 5b4c302d87b5039258fb3785c0d1e18775e4cf7d.


Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/ed48fad6
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/ed48fad6
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/ed48fad6

Branch: refs/heads/master
Commit: ed48fad6cd8a701973a05a69f29db001a2ce978f
Parents: 88f3276
Author: Sun Dapeng <sdp@apache.org>
Authored: Thu Jun 30 14:39:39 2016 +0800
Committer: Sun Dapeng <sdp@apache.org>
Committed: Thu Jun 30 14:39:39 2016 +0800

----------------------------------------------------------------------
 .../org/apache/commons/crypto/jna/OpensslJnaCipher.java   |  9 ++-------
 .../apache/commons/crypto/jna/OpensslJnaCipherTest.java   | 10 ++++++++++
 2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/ed48fad6/src/main/java/org/apache/commons/crypto/jna/OpensslJnaCipher.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpensslJnaCipher.java b/src/main/java/org/apache/commons/crypto/jna/OpensslJnaCipher.java
index db1cd31..05ee367 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpensslJnaCipher.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpensslJnaCipher.java
@@ -38,7 +38,6 @@ import org.apache.commons.crypto.cipher.CryptoCipher;
 import org.apache.commons.crypto.utils.Utils;
 
 import com.sun.jna.NativeLong;
-import com.sun.jna.Pointer;
 import com.sun.jna.ptr.PointerByReference;
 
 /**
@@ -49,7 +48,7 @@ class OpensslJnaCipher implements CryptoCipher {
     private final static int AES_BLOCK_SIZE = 16;
     
     private PointerByReference algo;
-    private PointerByReference context;
+    private final PointerByReference context;
     private final AlgorithmMode algMode;
     private final int padding;
     private final String transformation;
@@ -120,9 +119,6 @@ class OpensslJnaCipher implements CryptoCipher {
             }
         }
         
-        if (context != null && Pointer.NULL == context.getValue()) {
-            context = OpensslNativeJna.EVP_CIPHER_CTX_new();
-        }
         int retVal = OpensslNativeJna.EVP_CipherInit_ex(context, algo, null, key.getEncoded(),
iv, cipherMode);
         throwOnError(retVal);
         OpensslNativeJna.EVP_CIPHER_CTX_set_padding(context, padding);
@@ -237,10 +233,9 @@ class OpensslJnaCipher implements CryptoCipher {
      */
     @Override
     public void close() {
-        if(context != null && Pointer.NULL != context.getValue()) {
+        if(context != null) {
             OpensslNativeJna.EVP_CIPHER_CTX_cleanup(context);
             OpensslNativeJna.EVP_CIPHER_CTX_free(context);
-            context.setValue(Pointer.NULL);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/ed48fad6/src/test/java/org/apache/commons/crypto/jna/OpensslJnaCipherTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/crypto/jna/OpensslJnaCipherTest.java b/src/test/java/org/apache/commons/crypto/jna/OpensslJnaCipherTest.java
index d30586c..2d01ffa 100644
--- a/src/test/java/org/apache/commons/crypto/jna/OpensslJnaCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/OpensslJnaCipherTest.java
@@ -19,6 +19,7 @@
 package org.apache.commons.crypto.jna;
 
 import org.apache.commons.crypto.cipher.AbstractCipherTest;
+import org.apache.commons.crypto.jna.OpensslJnaCipher;
 
 public class OpensslJnaCipherTest extends AbstractCipherTest {
 
@@ -32,4 +33,13 @@ public class OpensslJnaCipherTest extends AbstractCipherTest {
         cipherClass = OpensslJnaCipher.class.getName();
     }
 
+    @Override
+    public void closeTestRepeat() {
+        System.err.println("closeTestRepeat() Causes JVM crash");
+    }
+
+    @Override
+    public void reInitAfterClose() {
+        System.err.println("reInitAfterClose() Causes JVM crash");
+    }
 }


Mime
View raw message