zhujt20 commented on code in PR #233:
URL: https://github.com/apache/tsfile/pull/233#discussion_r1810453818


##########
java/tsfile/src/main/java/org/apache/tsfile/encrypt/EncryptUtils.java:
##########
@@ -109,37 +158,61 @@ public static IEncryptor getDefaultEncryptor() {
         md.update("IoTDB is the best".getBytes());
         
md.update(TSFileDescriptor.getInstance().getConfig().getEncryptKey().getBytes());
         dataEncryptKey = md.digest();
-      } catch (Exception e1) {
-        throw new EncryptException("md5 function not found while using md5 to 
generate data key");
+      } catch (Exception e) {
+        throw new EncryptException(
+            "md5 function not found while using md5 to generate data key", e);
       }
     } else {
-      encryptType = EncryptionType.UNENCRYPTED;
+      encryptType = "org.apache.tsfile.encrypt.UNENCRYPTED";
       dataEncryptKey = null;
     }
-    return IEncryptor.getEncryptor(encryptType, dataEncryptKey);
+    try {
+      Class<?> encryptTypeClass = Class.forName(encryptType);
+      java.lang.reflect.Constructor<?> constructor =
+          encryptTypeClass.getDeclaredConstructor(byte[].class);
+      return ((IEncrypt) constructor.newInstance(dataEncryptKey));

Review Comment:
   Actually the constructor here will only be used once.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to