Skip to content

Commit e2b4a71

Browse files
committed
Add a flag to detect GAE platform
1 parent d04c795 commit e2b4a71

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,26 @@ enum DirectBufferConstructorType {
5959

6060
boolean hasUnsafe = false;
6161
try {
62-
Class.forName("sun.misc.Unsafe");
63-
hasUnsafe = true;
62+
hasUnsafe = Class.forName("sun.misc.Unsafe") != null;
6463
}
65-
catch(ClassNotFoundException e) {
64+
catch(Exception e) {
6665
}
6766

6867
// Detect android VM
6968
boolean isAndroid = System.getProperty("java.runtime.name", "").toLowerCase().contains("android");
7069

70+
// Is Google App Engine?
71+
boolean isGAE = System.getProperty("com.google.appengine.runtime.version") != null;
72+
7173
// For Java6, android and JVM that has no Unsafe class, use Universal MessageBuffer
7274
boolean useUniversalBuffer =
7375
Boolean.parseBoolean(System.getProperty("msgpack.universal-buffer", "false"))
7476
|| isAndroid
77+
|| isGAE
7578
|| !isJavaAtLeast7
7679
|| !hasUnsafe;
7780

78-
// We need to use reflection to find MessageBuffer implementation classes because
81+
// We need to use reflection to find MessageBuffer implementation classes abecause
7982
// importing these classes creates TypeProfile and adds some overhead to method calls.
8083
String bufferClsName;
8184
if(useUniversalBuffer) {

0 commit comments

Comments
 (0)