jdaugherty commented on code in PR #15828:
URL: https://github.com/apache/grails-core/pull/15828#discussion_r3538028243


##########
grails-codecs-core/src/main/groovy/org/grails/plugins/codecs/Base64CodecExtensionMethods.groovy:
##########
@@ -24,32 +24,35 @@ import org.codehaus.groovy.runtime.NullObject
 
 import org.apache.commons.codec.binary.Base64
 
+import groovy.transform.CompileStatic
+
 /**
  * A codec that encodes and decodes Objects using Base64 encoding.
  *
  * @author Drew Varner
  */
+@CompileStatic
 class Base64CodecExtensionMethods {
 
-    static encodeAsBase64(theTarget) {
+    static Object encodeAsBase64(Object theTarget) {
         if (theTarget == null || theTarget instanceof NullObject) {
             return null
         }
 
         if (theTarget instanceof Byte[] || theTarget instanceof byte[]) {
-            return new String(Base64.encodeBase64(theTarget))
+            return new 
String(Base64.encodeBase64(DigestUtils.toByteArray(theTarget)), 
StandardCharsets.UTF_8)
         }
 
-        return new 
String(Base64.encodeBase64(theTarget.toString().getBytes(StandardCharsets.UTF_8)))
+        return new 
String(Base64.encodeBase64(theTarget.toString().getBytes(StandardCharsets.UTF_8)),
 StandardCharsets.UTF_8)
     }
 
-    static decodeBase64(theTarget) {
+    static Object decodeBase64(Object theTarget) {
         if (theTarget == null || theTarget instanceof NullObject) {
             return null
         }
 
         if (theTarget instanceof Byte[] || theTarget instanceof byte[]) {
-            return Base64.decodeBase64(theTarget)
+            return Base64.decodeBase64(DigestUtils.toByteArray(theTarget))
         }
 
         return 
Base64.decodeBase64(theTarget.toString().getBytes(StandardCharsets.UTF_8))

Review Comment:
   I think you should take the opportunity to make UTF_8 an added method 
argument that's defaulted



-- 
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