Skip to content

Using a faster version of getBytes. #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ However 1.0.0 Beta fixes a *lot* of problems over 0.2.x, so even as it is called
I'd recommend to use the beta instead of the 0.2.3 even for production.

froh42 will return to develop for java-apns in October, so I expect the 1.0.0 final
to be released start of November.
to be released start of November. Edited!


Introduction
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/notnoop/apns/internal/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.net.Socket;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
Expand Down Expand Up @@ -110,11 +111,7 @@ public static String encodeHex(final byte[] bytes) {
}

public static byte[] toUTF8Bytes(final String s) {
try {
return s.getBytes("UTF-8");
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return s.getBytes(StandardCharsets.UTF_8);
}

public static byte[] marshall(final byte command, final byte[] deviceToken, final byte[] payload) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
//import java.net.InetSocketAddress;
//import java.net.Proxy;
//import java.net.Socket;
Expand Down Expand Up @@ -72,6 +73,6 @@ public void invalidProxyParams() throws IOException {
}

private InputStream inputStream(String content) throws IOException {
return new ByteArrayInputStream(content.getBytes("UTF-8"));
return new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
}
}