File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
objectbox-java/src/main/java/io/objectbox/sync Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change 1
1
package io .objectbox .sync ;
2
2
3
- import java .io . UnsupportedEncodingException ;
3
+ import java .nio . charset . StandardCharsets ;
4
4
import java .util .Arrays ;
5
5
6
6
import javax .annotation .Nullable ;
@@ -21,16 +21,18 @@ public final class SyncCredentialsToken extends SyncCredentials {
21
21
this .token = null ;
22
22
}
23
23
24
- SyncCredentialsToken (CredentialsType type , @ SuppressWarnings ( "NullableProblems" ) byte [] token ) {
24
+ SyncCredentialsToken (CredentialsType type , byte [] token ) {
25
25
this (type );
26
+ // Annotations do not guarantee non-null values
27
+ //noinspection ConstantValue
26
28
if (token == null || token .length == 0 ) {
27
29
throw new IllegalArgumentException ("Token must not be empty" );
28
30
}
29
31
this .token = token ;
30
32
}
31
33
32
34
SyncCredentialsToken (CredentialsType type , String token ) {
33
- this (type , asUtf8Bytes ( token ));
35
+ this (type , token . getBytes ( StandardCharsets . UTF_8 ));
34
36
}
35
37
36
38
@ Nullable
@@ -56,12 +58,4 @@ public void clear() {
56
58
this .token = null ;
57
59
}
58
60
59
- private static byte [] asUtf8Bytes (String token ) {
60
- try {
61
- //noinspection CharsetObjectCanBeUsed On Android not available until SDK 19.
62
- return token .getBytes ("UTF-8" );
63
- } catch (UnsupportedEncodingException e ) {
64
- throw new RuntimeException (e );
65
- }
66
- }
67
61
}
You can’t perform that action at this time.
0 commit comments