commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc Ende (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CODEC-99) Base64.encodeBase64String() shouldn't chunk
Date Tue, 26 Oct 2010 11:45:18 GMT

    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924940#action_12924940
] 

Marc Ende  commented on CODEC-99:
---------------------------------

If I'd like to encode a small string, I'll agree:

new Base64().encodeToString(...)

But it doesn't matter in this point if this is chunked or not. 

Other people which like to encode larger strings won't use new Base64(0) or new Base64(-1)
when they wanted chunked
files. Otherwise they've read the docs which mentioned the way to use unchunked. I think it
wouldn't break upwards compatibility because there is no really use case where you'll instantiate
an Base64 encoder with 0 or less than 0 when it should be chunked. In these case even the
"convenience methods" should behaviour correctly. Or otherwise (to keep upwards compatibility)
it should be explicitly mentioned in the apidocs. 

Currently it looks like buying a car, choosing red as the color and only if you're opening
the right door the car became green. 

> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message