mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 18:29:45 +02:00
Bump "Error Prone" to 2.0.15
and fix a few things :)
This commit is contained in:
parent
ef0af66b21
commit
4c646436a5
246 changed files with 1122 additions and 124 deletions
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.util.stringencoder.java7;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -514,7 +515,7 @@ public final class Base64
|
|||
} // end try
|
||||
catch (java.io.UnsupportedEncodingException uue)
|
||||
{
|
||||
return new String( baos.toByteArray() );
|
||||
return new String( baos.toByteArray(), Charset.defaultCharset() );
|
||||
} // end catch
|
||||
|
||||
} // end encode
|
||||
|
@ -642,7 +643,7 @@ public final class Base64
|
|||
} // end try
|
||||
catch (java.io.UnsupportedEncodingException uue)
|
||||
{
|
||||
return new String( baos.toByteArray() );
|
||||
return new String( baos.toByteArray(), Charset.defaultCharset() );
|
||||
} // end catch
|
||||
} // end if: compress
|
||||
|
||||
|
@ -687,7 +688,7 @@ public final class Base64
|
|||
} // end try
|
||||
catch (java.io.UnsupportedEncodingException uue)
|
||||
{
|
||||
return new String( outBuff, 0, e );
|
||||
return new String( outBuff, 0, e , Charset.defaultCharset());
|
||||
} // end catch
|
||||
|
||||
} // end else: don't compress
|
||||
|
@ -887,7 +888,7 @@ public final class Base64
|
|||
} // end try
|
||||
catch( java.io.UnsupportedEncodingException uee )
|
||||
{
|
||||
bytes = s.getBytes();
|
||||
bytes = s.getBytes( Charset.defaultCharset() );
|
||||
} // end catch
|
||||
//</change>
|
||||
|
||||
|
@ -1289,6 +1290,7 @@ public final class Base64
|
|||
* @return next byte
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public int read() throws java.io.IOException
|
||||
{
|
||||
// Do we need to get data?
|
||||
|
@ -1417,6 +1419,7 @@ public final class Base64
|
|||
* @return bytes read into array or -1 if end of stream is encountered.
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public int read( byte[] dest, int off, int len ) throws java.io.IOException
|
||||
{
|
||||
int i;
|
||||
|
@ -1530,6 +1533,7 @@ public final class Base64
|
|||
* @param theByte the byte to write
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public void write(int theByte) throws java.io.IOException
|
||||
{
|
||||
// Encoding suspended?
|
||||
|
@ -1591,6 +1595,7 @@ public final class Base64
|
|||
* @param len max number of bytes to read into array
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public void write( byte[] theBytes, int off, int len ) throws java.io.IOException
|
||||
{
|
||||
// Encoding suspended?
|
||||
|
@ -1636,6 +1641,7 @@ public final class Base64
|
|||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public void close() throws java.io.IOException
|
||||
{
|
||||
// 1. Ensure that pending characters are written
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.util.stringencoder.java7;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.stringencoder.StringEncoder;
|
||||
|
||||
|
||||
|
@ -44,12 +47,26 @@ public final class Java7Base64UrlSafeEncoder implements StringEncoder {
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encode(String s) {
|
||||
return Base64.encodeBytes(s.getBytes(), BASE64_ENCODER_FLAGS);
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = s.getBytes(StringUtils.UTF8);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
return Base64.encodeBytes(bytes, BASE64_ENCODER_FLAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String s) {
|
||||
return new String(Base64.decode(s, BASE64_ENCODER_FLAGS));
|
||||
try {
|
||||
return new String(Base64.decode(s, BASE64_ENCODER_FLAGS), StringUtils.UTF8);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue