diff --git a/appengine-java-logging/src/main/java/com/google/apphosting/logging/JsonFormatter.java b/appengine-java-logging/src/main/java/com/google/apphosting/logging/JsonFormatter.java
index 9fec754..9951785 100644
--- a/appengine-java-logging/src/main/java/com/google/apphosting/logging/JsonFormatter.java
+++ b/appengine-java-logging/src/main/java/com/google/apphosting/logging/JsonFormatter.java
@@ -28,95 +28,99 @@
* properties that App Engine expects.
*/
public class JsonFormatter extends Formatter {
- @Override
- public String format(LogRecord record) {
- Instant timestamp = Instant.ofEpochMilli(record.getMillis());
- StringWriter out = new StringWriter();
+ @Override
+ public String format(LogRecord record) {
+ Instant timestamp = Instant.ofEpochMilli(record.getMillis());
+ StringWriter out = new StringWriter();
- // Write using a simple JsonWriter rather than the more sophisticated Gson as we generally
- // will not need to serialize complex objects that require introspection and reflection.
- try (JsonWriter writer = new JsonWriter(out)) {
- writer.setSerializeNulls(false);
- writer.setHtmlSafe(false);
+ // Write using a simple JsonWriter rather than the more sophisticated Gson as we generally
+ // will not need to serialize complex objects that require introspection and reflection.
+ try (JsonWriter writer = new JsonWriter(out)) {
+ writer.setSerializeNulls(false);
+ writer.setHtmlSafe(false);
- writer.beginObject();
- writer.name("timestamp")
- .beginObject()
- .name("seconds").value(timestamp.getEpochSecond())
- .name("nanos").value(timestamp.getNano())
- .endObject();
- writer.name("severity").value(severity(record.getLevel()));
- writer.name("thread").value(Thread.currentThread().getName());
- writer.name("message").value(formatMessage(record));
+ writer.beginObject();
+ writer
+ .name("timestamp")
+ .beginObject()
+ .name("seconds")
+ .value(timestamp.getEpochSecond())
+ .name("nanos")
+ .value(timestamp.getNano())
+ .endObject();
+ writer.name("severity").value(severity(record.getLevel()));
+ writer.name("thread").value(Thread.currentThread().getName());
+ writer.name("message").value(formatMessage(record));
- // If there is a LogContext associated with this thread then add its properties.
- LogContext logContext = LogContext.current();
- if (logContext != null) {
- logContext.forEach((name, value) -> {
- try {
- writer.name(name);
- if (value == null) {
- writer.nullValue();
- } else if (value instanceof Boolean) {
- writer.value((boolean) value);
- } else if (value instanceof Number) {
- writer.value((Number) value);
- } else {
- writer.value(value.toString());
- }
- } catch (IOException e) {
- // Should not happen as StringWriter does not throw IOException
- throw new AssertionError(e);
- }
- });
- }
- writer.endObject();
- } catch (IOException e) {
- // Should not happen as StringWriter does not throw IOException
- throw new AssertionError(e);
- }
- out.append(System.lineSeparator());
- return out.toString();
+ // If there is a LogContext associated with this thread then add its properties.
+ LogContext logContext = LogContext.current();
+ if (logContext != null) {
+ logContext.forEach(
+ (name, value) -> {
+ try {
+ writer.name(name);
+ if (value == null) {
+ writer.nullValue();
+ } else if (value instanceof Boolean) {
+ writer.value((boolean) value);
+ } else if (value instanceof Number) {
+ writer.value((Number) value);
+ } else {
+ writer.value(value.toString());
+ }
+ } catch (IOException e) {
+ // Should not happen as StringWriter does not throw IOException
+ throw new AssertionError(e);
+ }
+ });
+ }
+ writer.endObject();
+ } catch (IOException e) {
+ // Should not happen as StringWriter does not throw IOException
+ throw new AssertionError(e);
}
+ out.append(System.lineSeparator());
+ return out.toString();
+ }
- @Override
- public synchronized String formatMessage(LogRecord record) {
- StringBuilder sb = new StringBuilder();
- if (record.getSourceClassName() != null) {
- sb.append(record.getSourceClassName());
- } else {
- sb.append(record.getLoggerName());
- }
- if (record.getSourceMethodName() != null) {
- sb.append(' ');
- sb.append(record.getSourceMethodName());
- }
- sb.append(": ");
- sb.append(super.formatMessage(record));
- Throwable thrown = record.getThrown();
- if (thrown != null) {
- StringWriter sw = new StringWriter();
- try (PrintWriter pw = new PrintWriter(sw);) {
- sb.append("\n");
- thrown.printStackTrace(pw);
- }
- sb.append(sw.getBuffer());
- }
- return sb.toString();
+ @Override
+ public synchronized String formatMessage(LogRecord record) {
+ StringBuilder sb = new StringBuilder();
+ if (record.getSourceClassName() != null) {
+ sb.append(record.getSourceClassName());
+ } else {
+ sb.append(record.getLoggerName());
}
+ if (record.getSourceMethodName() != null) {
+ sb.append(' ');
+ sb.append(record.getSourceMethodName());
+ }
+ sb.append(": ");
+ sb.append(super.formatMessage(record));
+ Throwable thrown = record.getThrown();
+ if (thrown != null) {
+ StringWriter sw = new StringWriter();
+ try (PrintWriter pw = new PrintWriter(sw); ) {
+ sb.append("\n");
+ thrown.printStackTrace(pw);
+ }
+ sb.append(sw.getBuffer());
+ }
+ return sb.toString();
+ }
- private static String severity(Level level) {
- int intLevel = level.intValue();
+ private static String severity(Level level) {
+ int intLevel = level.intValue();
- if (intLevel >= Level.SEVERE.intValue()) {
- return "ERROR";
- } else if (intLevel >= Level.WARNING.intValue()) {
- return "WARNING";
- } else if (intLevel >= Level.INFO.intValue()) {
- return "INFO";
- } else {
- // There's no trace, so we'll map everything below this to debug.
- return "DEBUG";
- }
+ if (intLevel >= Level.SEVERE.intValue()) {
+ return "ERROR";
+ } else if (intLevel >= Level.WARNING.intValue()) {
+ return "WARNING";
+ } else if (intLevel >= Level.INFO.intValue()) {
+ return "INFO";
+ } else {
+ // There's no trace, so we'll map everything below this to debug.
+ return "DEBUG";
}
+ }
}
diff --git a/appengine-java-logging/src/main/java/com/google/apphosting/logging/LogContext.java b/appengine-java-logging/src/main/java/com/google/apphosting/logging/LogContext.java
index 41efd13..401fe69 100644
--- a/appengine-java-logging/src/main/java/com/google/apphosting/logging/LogContext.java
+++ b/appengine-java-logging/src/main/java/com/google/apphosting/logging/LogContext.java
@@ -25,20 +25,19 @@
*
This is an implementation of a Mapped Diagnostic Context for use with the java.util.logging
* framework.
*/
-public class LogContext extends ConcurrentHashMap{
+public class LogContext extends ConcurrentHashMap {
- private static final ThreadLocal threadContext = new ThreadLocal()
- {
- @Override
- protected LogContext initialValue() {
- return new LogContext();
- }
- };
+ private static final ThreadLocal threadContext =
+ new ThreadLocal() {
+ @Override
+ protected LogContext initialValue() {
+ return new LogContext();
+ }
+ };
private final Map values = new ConcurrentHashMap<>();
- private LogContext() {
- }
+ private LogContext() {}
/**
* Returns the log context associated with the current Thread.
@@ -79,5 +78,4 @@ public T get(String name, Class type) {
public Stream> stream() {
return values.entrySet().stream();
}
-
}
diff --git a/appengine-java-logging/src/test/java/com/google/apphosting/logging/JsonFormatterTest.java b/appengine-java-logging/src/test/java/com/google/apphosting/logging/JsonFormatterTest.java
index 74d1dc1..df1d645 100644
--- a/appengine-java-logging/src/test/java/com/google/apphosting/logging/JsonFormatterTest.java
+++ b/appengine-java-logging/src/test/java/com/google/apphosting/logging/JsonFormatterTest.java
@@ -27,73 +27,76 @@
public class JsonFormatterTest {
- private JsonFormatter formatter = new JsonFormatter();
+ private JsonFormatter formatter = new JsonFormatter();
- @Test
- public void formatProducesExpectedJsonData() throws Exception {
- LogRecord record = new LogRecord(Level.INFO, "message");
- record.setMillis(12345_678);
- record.setLoggerName("logger");
- LogContext.current().put("traceId", "abcdef");
+ @Test
+ public void formatProducesExpectedJsonData() throws Exception {
+ LogRecord record = new LogRecord(Level.INFO, "message");
+ record.setMillis(12345_678);
+ record.setLoggerName("logger");
+ LogContext.current().put("traceId", "abcdef");
- String logLine = formatter.format(record);
- assertThat(logLine, endsWith(System.lineSeparator()));
+ String logLine = formatter.format(record);
+ assertThat(logLine, endsWith(System.lineSeparator()));
- JsonData data = new Gson().fromJson(logLine, JsonData.class);
- assertEquals("INFO", data.severity);
- assertEquals(12345, data.timestamp.seconds);
- assertEquals(678_000_000, data.timestamp.nanos);
- assertEquals(Thread.currentThread().getName(), data.thread);
- assertEquals("logger: message", data.message);
- assertEquals("abcdef", data.traceId);
- }
+ JsonData data = new Gson().fromJson(logLine, JsonData.class);
+ assertEquals("INFO", data.severity);
+ assertEquals(12345, data.timestamp.seconds);
+ assertEquals(678_000_000, data.timestamp.nanos);
+ assertEquals(Thread.currentThread().getName(), data.thread);
+ assertEquals("logger: message", data.message);
+ assertEquals("abcdef", data.traceId);
+ }
- @Test
- public void messageIncludesLoggerName() throws Exception {
- LogRecord record = new LogRecord(Level.INFO, "message");
- record.setLoggerName("logger");
- assertEquals("logger: message", formatter.formatMessage(record));
- }
+ @Test
+ public void messageIncludesLoggerName() throws Exception {
+ LogRecord record = new LogRecord(Level.INFO, "message");
+ record.setLoggerName("logger");
+ assertEquals("logger: message", formatter.formatMessage(record));
+ }
- @Test
- public void messageIncludesClassName() throws Exception {
- LogRecord record = new LogRecord(Level.INFO, "message");
- record.setSourceClassName("class");
- record.setLoggerName("logger");
- assertEquals("class: message", formatter.formatMessage(record));
- }
+ @Test
+ public void messageIncludesClassName() throws Exception {
+ LogRecord record = new LogRecord(Level.INFO, "message");
+ record.setSourceClassName("class");
+ record.setLoggerName("logger");
+ assertEquals("class: message", formatter.formatMessage(record));
+ }
- @Test
- public void messageIncludesMethodName() throws Exception {
- LogRecord record = new LogRecord(Level.INFO, "message");
- record.setSourceClassName("class");
- record.setSourceMethodName("method");
- assertEquals("class method: message", formatter.formatMessage(record));
- }
+ @Test
+ public void messageIncludesMethodName() throws Exception {
+ LogRecord record = new LogRecord(Level.INFO, "message");
+ record.setSourceClassName("class");
+ record.setSourceMethodName("method");
+ assertEquals("class method: message", formatter.formatMessage(record));
+ }
- @Test
- public void messageIncludesStackTrace() throws Exception {
- LogRecord record = new LogRecord(Level.INFO, "message");
- record.setLoggerName("logger");
- record.setThrown(new Throwable("thrown").fillInStackTrace());
- String message = formatter.formatMessage(record);
- BufferedReader reader = new BufferedReader(new StringReader(message));
- assertEquals("logger: message", reader.readLine());
- assertEquals("java.lang.Throwable: thrown", reader.readLine());
- assertTrue(reader.readLine()
- .startsWith("\tat " + getClass().getName() + ".messageIncludesStackTrace"));
- }
+ @Test
+ public void messageIncludesStackTrace() throws Exception {
+ LogRecord record = new LogRecord(Level.INFO, "message");
+ record.setLoggerName("logger");
+ record.setThrown(new Throwable("thrown").fillInStackTrace());
+ String message = formatter.formatMessage(record);
+ BufferedReader reader = new BufferedReader(new StringReader(message));
+ assertEquals("logger: message", reader.readLine());
+ assertEquals("java.lang.Throwable: thrown", reader.readLine());
+ assertTrue(
+ reader
+ .readLine()
+ .startsWith("\tat " + getClass().getName() + ".messageIncludesStackTrace"));
+ }
- // Something that JSON can parser the JSON into
- public static class JsonData {
- public static class LogTimestamp {
- public long seconds;
- public long nanos;
- }
- public LogTimestamp timestamp;
- public String severity;
- public String thread;
- public String message;
- public String traceId;
+ // Something that JSON can parser the JSON into
+ public static class JsonData {
+ public static class LogTimestamp {
+ public long seconds;
+ public long nanos;
}
-}
\ No newline at end of file
+
+ public LogTimestamp timestamp;
+ public String severity;
+ public String thread;
+ public String message;
+ public String traceId;
+ }
+}
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DatastoreSessionStore.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DatastoreSessionStore.java
index c8c898d..a5d8106 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DatastoreSessionStore.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DatastoreSessionStore.java
@@ -1,19 +1,18 @@
/**
* Copyright 2011 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.runtime;
import static com.google.apphosting.runtime.SessionManagerUtil.deserialize;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DeferredDatastoreSessionStore.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DeferredDatastoreSessionStore.java
index 5bb3031..ea11203 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DeferredDatastoreSessionStore.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/DeferredDatastoreSessionStore.java
@@ -1,19 +1,18 @@
/**
* Copyright 2011 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.runtime;
import static com.google.appengine.api.taskqueue.RetryOptions.Builder.withTaskAgeLimitSeconds;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/MemcacheSessionStore.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/MemcacheSessionStore.java
index 619f87e..93eda41 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/MemcacheSessionStore.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/MemcacheSessionStore.java
@@ -1,20 +1,18 @@
/**
* Copyright 2011 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.runtime;
import static com.google.apphosting.runtime.SessionManagerUtil.deserialize;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionData.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionData.java
index 5d01f32..e346e08 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionData.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionData.java
@@ -1,20 +1,18 @@
/**
* Copyright 2009 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.runtime;
import java.util.HashMap;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java
index fe2d801..bc0329b 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java
@@ -1,20 +1,18 @@
/**
* Copyright 2012 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.runtime;
import java.io.ByteArrayInputStream;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionStore.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionStore.java
index 4443f95..90ed30f 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionStore.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/SessionStore.java
@@ -1,19 +1,18 @@
/**
* Copyright 2011 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.runtime;
import java.util.Map;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/AbstractIntervalTimer.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/AbstractIntervalTimer.java
index 3e7f71d..c591bb4 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/AbstractIntervalTimer.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/AbstractIntervalTimer.java
@@ -1,20 +1,18 @@
/**
* Copyright 2007 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.runtime.timer;
/**
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/Timer.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/Timer.java
index 7f47d35..68c9849 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/Timer.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/runtime/timer/Timer.java
@@ -1,20 +1,18 @@
/**
* Copyright 2007 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.runtime.timer;
public interface Timer {
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineConfigException.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineConfigException.java
index 42d1de8..128eb3b 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineConfigException.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineConfigException.java
@@ -1,19 +1,18 @@
/**
* Copyright 2008 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.config;
/**
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXml.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXml.java
index c0d8a2a..04ad607 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXml.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXml.java
@@ -41,7 +41,11 @@ public class AppEngineWebXml implements Cloneable {
/**
* Enumeration of supported scaling types.
*/
- public static enum ScalingType {AUTOMATIC, MANUAL, BASIC}
+ public static enum ScalingType {
+ AUTOMATIC,
+ MANUAL,
+ BASIC
+ }
// System properties defined by the application in appengine-web.xml
private final Map systemProperties = Maps.newHashMap();
@@ -64,7 +68,7 @@ public static enum ScalingType {AUTOMATIC, MANUAL, BASIC}
public static final String WARMUP_SERVICE = "warmup";
public static final String URL_HANDLER_URLFETCH = "urlfetch";
- public static final String URL_HANDLER_NATIVE= "native";
+ public static final String URL_HANDLER_NATIVE = "native";
private String appId;
@@ -359,8 +363,8 @@ public void excludeResourcePattern(String url) {
public void addUserPermission(String className, String name, String actions) {
if (className.startsWith("java.")) {
- throw new AppEngineConfigException("Cannot specify user-permissions for " +
- "classes in java.* packages.");
+ throw new AppEngineConfigException(
+ "Cannot specify user-permissions for " + "classes in java.* packages.");
}
userPermissions.add(new UserPermission(className, name, actions));
@@ -369,22 +373,20 @@ public void addUserPermission(String className, String name, String actions) {
public Permissions getUserPermissions() {
Permissions permissions = new Permissions();
for (UserPermission permission : userPermissions) {
- permissions.add(new UnresolvedPermission(permission.getClassName(),
- permission.getName(),
- permission.getActions(),
- null));
+ permissions.add(
+ new UnresolvedPermission(
+ permission.getClassName(), permission.getName(), permission.getActions(), null));
}
permissions.setReadOnly();
return permissions;
}
-
public void setPublicRoot(String root) {
if (root.indexOf('*') != -1) {
throw new AppEngineConfigException("public-root cannot contain wildcards");
}
if (root.endsWith("/")) {
- root = root.substring(0, root.length() - 1);
+ root = root.substring(0, root.length() - 1);
}
if (root.length() > 0 && !root.startsWith("/")) {
root = "/" + root;
@@ -520,8 +522,12 @@ public void setUrlStreamHandlerType(String urlStreamHandlerType) {
if (!URL_HANDLER_URLFETCH.equals(urlStreamHandlerType)
&& !URL_HANDLER_NATIVE.equals(urlStreamHandlerType)) {
throw new AppEngineConfigException(
- "url-stream-handler must be " + URL_HANDLER_URLFETCH + " or " + URL_HANDLER_NATIVE +
- " given " + urlStreamHandlerType);
+ "url-stream-handler must be "
+ + URL_HANDLER_URLFETCH
+ + " or "
+ + URL_HANDLER_NATIVE
+ + " given "
+ + urlStreamHandlerType);
}
this.urlStreamHandlerType = urlStreamHandlerType;
}
@@ -672,7 +678,8 @@ public boolean equals(Object o) {
if (threadsafeValueProvided != that.threadsafeValueProvided) {
return false;
}
- if (autoIdPolicy != null ? !autoIdPolicy.equals(that.autoIdPolicy)
+ if (autoIdPolicy != null
+ ? !autoIdPolicy.equals(that.autoIdPolicy)
: that.autoIdPolicy != null) {
return false;
}
@@ -682,21 +689,24 @@ public boolean equals(Object o) {
if (useSessions != that.useSessions) {
return false;
}
- if (adminConsolePages != null ? !adminConsolePages.equals(that.adminConsolePages)
+ if (adminConsolePages != null
+ ? !adminConsolePages.equals(that.adminConsolePages)
: that.adminConsolePages != null) {
return false;
}
if (appId != null ? !appId.equals(that.appId) : that.appId != null) {
return false;
}
- if (majorVersionId != null ? !majorVersionId.equals(that.majorVersionId)
+ if (majorVersionId != null
+ ? !majorVersionId.equals(that.majorVersionId)
: that.majorVersionId != null) {
return false;
}
if (service != null ? !service.equals(that.service) : that.service != null) {
return false;
}
- if (instanceClass != null ? !instanceClass.equals(that.instanceClass)
+ if (instanceClass != null
+ ? !instanceClass.equals(that.instanceClass)
: that.instanceClass != null) {
return false;
}
@@ -712,75 +722,90 @@ public boolean equals(Object o) {
if (appRoot != null ? !appRoot.equals(that.appRoot) : that.appRoot != null) {
return false;
}
- if (asyncSessionPersistenceQueueName != null ? !asyncSessionPersistenceQueueName
- .equals(that.asyncSessionPersistenceQueueName)
+ if (asyncSessionPersistenceQueueName != null
+ ? !asyncSessionPersistenceQueueName.equals(that.asyncSessionPersistenceQueueName)
: that.asyncSessionPersistenceQueueName != null) {
return false;
}
- if (envVariables != null ? !envVariables.equals(that.envVariables)
+ if (envVariables != null
+ ? !envVariables.equals(that.envVariables)
: that.envVariables != null) {
return false;
}
- if (errorHandlers != null ? !errorHandlers.equals(that.errorHandlers)
+ if (errorHandlers != null
+ ? !errorHandlers.equals(that.errorHandlers)
: that.errorHandlers != null) {
return false;
}
- if (inboundServices != null ? !inboundServices.equals(that.inboundServices)
+ if (inboundServices != null
+ ? !inboundServices.equals(that.inboundServices)
: that.inboundServices != null) {
return false;
}
- if (majorVersionId != null ? !majorVersionId.equals(that.majorVersionId)
+ if (majorVersionId != null
+ ? !majorVersionId.equals(that.majorVersionId)
: that.majorVersionId != null) {
return false;
}
- if (sourceLanguage != null ? !sourceLanguage.equals(that.sourceLanguage)
+ if (sourceLanguage != null
+ ? !sourceLanguage.equals(that.sourceLanguage)
: that.sourceLanguage != null) {
return false;
}
if (publicRoot != null ? !publicRoot.equals(that.publicRoot) : that.publicRoot != null) {
return false;
}
- if (resourceExcludePattern != null ? !resourceExcludePattern.equals(that.resourceExcludePattern)
+ if (resourceExcludePattern != null
+ ? !resourceExcludePattern.equals(that.resourceExcludePattern)
: that.resourceExcludePattern != null) {
return false;
}
- if (resourceFileExcludes != null ? !resourceFileExcludes.equals(that.resourceFileExcludes)
+ if (resourceFileExcludes != null
+ ? !resourceFileExcludes.equals(that.resourceFileExcludes)
: that.resourceFileExcludes != null) {
return false;
}
- if (resourceFileIncludes != null ? !resourceFileIncludes.equals(that.resourceFileIncludes)
+ if (resourceFileIncludes != null
+ ? !resourceFileIncludes.equals(that.resourceFileIncludes)
: that.resourceFileIncludes != null) {
return false;
}
- if (resourceIncludePattern != null ? !resourceIncludePattern.equals(that.resourceIncludePattern)
+ if (resourceIncludePattern != null
+ ? !resourceIncludePattern.equals(that.resourceIncludePattern)
: that.resourceIncludePattern != null) {
return false;
}
- if (staticExcludePattern != null ? !staticExcludePattern.equals(that.staticExcludePattern)
+ if (staticExcludePattern != null
+ ? !staticExcludePattern.equals(that.staticExcludePattern)
: that.staticExcludePattern != null) {
return false;
}
- if (staticFileExcludes != null ? !staticFileExcludes.equals(that.staticFileExcludes)
+ if (staticFileExcludes != null
+ ? !staticFileExcludes.equals(that.staticFileExcludes)
: that.staticFileExcludes != null) {
return false;
}
- if (staticFileIncludes != null ? !staticFileIncludes.equals(that.staticFileIncludes)
+ if (staticFileIncludes != null
+ ? !staticFileIncludes.equals(that.staticFileIncludes)
: that.staticFileIncludes != null) {
return false;
}
- if (staticIncludePattern != null ? !staticIncludePattern.equals(that.staticIncludePattern)
+ if (staticIncludePattern != null
+ ? !staticIncludePattern.equals(that.staticIncludePattern)
: that.staticIncludePattern != null) {
return false;
}
- if (systemProperties != null ? !systemProperties.equals(that.systemProperties)
+ if (systemProperties != null
+ ? !systemProperties.equals(that.systemProperties)
: that.systemProperties != null) {
return false;
}
- if (betaSettings != null ? !betaSettings.equals(that.betaSettings) : that.betaSettings != null) {
+ if (betaSettings != null
+ ? !betaSettings.equals(that.betaSettings)
+ : that.betaSettings != null) {
return false;
}
- if (healthCheck != null ? !healthCheck.equals(that.healthCheck)
- : that.healthCheck != null) {
+ if (healthCheck != null ? !healthCheck.equals(that.healthCheck) : that.healthCheck != null) {
return false;
}
if (resources != null ? !resources.equals(that.resources) : that.resources != null) {
@@ -789,24 +814,27 @@ public boolean equals(Object o) {
if (network != null ? !network.equals(that.network) : that.network != null) {
return false;
}
- if (userPermissions != null ? !userPermissions.equals(that.userPermissions)
+ if (userPermissions != null
+ ? !userPermissions.equals(that.userPermissions)
: that.userPermissions != null) {
return false;
}
- if (apiConfig != null ? !apiConfig.equals(that.apiConfig)
- : that.apiConfig != null) {
+ if (apiConfig != null ? !apiConfig.equals(that.apiConfig) : that.apiConfig != null) {
return false;
}
- if (apiEndpointIds != null ? !apiEndpointIds.equals(that.apiEndpointIds)
+ if (apiEndpointIds != null
+ ? !apiEndpointIds.equals(that.apiEndpointIds)
: that.apiEndpointIds != null) {
return false;
}
- if (classLoaderConfig != null ? !classLoaderConfig.equals(that.classLoaderConfig) :
- that.classLoaderConfig != null) {
+ if (classLoaderConfig != null
+ ? !classLoaderConfig.equals(that.classLoaderConfig)
+ : that.classLoaderConfig != null) {
return false;
}
- if (urlStreamHandlerType != null ? !urlStreamHandlerType.equals(that.urlStreamHandlerType) :
- that.urlStreamHandlerType != null) {
+ if (urlStreamHandlerType != null
+ ? !urlStreamHandlerType.equals(that.urlStreamHandlerType)
+ : that.urlStreamHandlerType != null) {
return false;
}
if (useGoogleConnectorJ != that.useGoogleConnectorJ) {
@@ -833,8 +861,10 @@ public int hashCode() {
result = 31 * result + (useSessions ? 1 : 0);
result = 31 * result + (asyncSessionPersistence ? 1 : 0);
result =
- 31 * result + (asyncSessionPersistenceQueueName != null ? asyncSessionPersistenceQueueName
- .hashCode() : 0);
+ 31 * result
+ + (asyncSessionPersistenceQueueName != null
+ ? asyncSessionPersistenceQueueName.hashCode()
+ : 0);
result = 31 * result + (staticFileIncludes != null ? staticFileIncludes.hashCode() : 0);
result = 31 * result + (staticFileExcludes != null ? staticFileExcludes.hashCode() : 0);
result = 31 * result + (resourceFileIncludes != null ? resourceFileIncludes.hashCode() : 0);
@@ -893,8 +923,7 @@ public boolean includesStatic(String path) {
} else {
staticRoot = "**";
}
- staticIncludePattern = Pattern.compile(
- makeRegexp(Collections.singletonList(staticRoot)));
+ staticIncludePattern = Pattern.compile(makeRegexp(Collections.singletonList(staticRoot)));
} else {
List patterns = new ArrayList();
for (StaticFileInclude include : staticFileIncludes) {
@@ -921,7 +950,7 @@ public boolean includesStatic(String path) {
* anything from the {@code includes} set.
*/
public boolean includes(String path, Pattern includes, Pattern excludes) {
- assert(includes != null);
+ assert (includes != null);
if (!includes.matcher(path).matches()) {
return false;
}
@@ -1110,7 +1139,7 @@ public boolean equals(Object obj) {
if (!pattern.equals(other.pattern)) {
return false;
}
- } else { // pattern == null
+ } else { // pattern == null
if (other.pattern != null) {
return false;
}
@@ -1122,7 +1151,7 @@ public boolean equals(Object obj) {
if (!expiration.equals(other.expiration)) {
return false;
}
- } else { // expiration == null
+ } else { // expiration == null
if (other.expiration != null) {
return false;
}
@@ -1134,7 +1163,7 @@ public boolean equals(Object obj) {
if (!httpHeaders.equals(other.httpHeaders)) {
return false;
}
- } else { // httpHeaders == null
+ } else { // httpHeaders == null
if (other.httpHeaders != null) {
return false;
}
@@ -1174,16 +1203,30 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
AdminConsolePage other = (AdminConsolePage) obj;
if (name == null) {
- if (other.name != null) return false;
- } else if (!name.equals(other.name)) return false;
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
if (url == null) {
- if (other.url != null) return false;
- } else if (!url.equals(other.url)) return false;
+ if (other.url != null) {
+ return false;
+ }
+ } else if (!url.equals(other.url)) {
+ return false;
+ }
return true;
}
}
@@ -1214,8 +1257,7 @@ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((file == null) ? 0 : file.hashCode());
- result = prime * result +
- ((errorCode == null) ? 0 : errorCode.hashCode());
+ result = prime * result + ((errorCode == null) ? 0 : errorCode.hashCode());
return result;
}
@@ -1276,16 +1318,30 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {
- if (this == obj) { return true; }
- if (obj == null) { return false; }
- if (getClass() != obj.getClass()) { return false; }
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
ApiConfig other = (ApiConfig) obj;
if (servletClass == null) {
- if (other.servletClass != null) { return false; }
- } else if (!servletClass.equals(other.servletClass)) { return false; }
+ if (other.servletClass != null) {
+ return false;
+ }
+ } else if (!servletClass.equals(other.servletClass)) {
+ return false;
+ }
if (url == null) {
- if (other.url != null) { return false; }
- } else if (!url.equals(other.url)) { return false; }
+ if (other.url != null) {
+ return false;
+ }
+ } else if (!url.equals(other.url)) {
+ return false;
+ }
return true;
}
@@ -1294,7 +1350,7 @@ public String toString() {
return "ApiConfig{servletClass=\"" + servletClass + "\", url=\"" + url + "\"}";
}
}
-
+
/**
* Holder for automatic settings.
*/
@@ -1348,7 +1404,7 @@ public String getMaxPendingLatency() {
* Sets maxPendingLatency. Normalizes empty and null inputs to null.
*/
public void setMaxPendingLatency(String maxPendingLatency) {
- this.maxPendingLatency = toNullIfEmptyOrWhitespace(maxPendingLatency);
+ this.maxPendingLatency = toNullIfEmptyOrWhitespace(maxPendingLatency);
}
public String getMinIdleInstances() {
@@ -1359,7 +1415,7 @@ public String getMinIdleInstances() {
* Sets minIdleInstances. Normalizes empty and null inputs to null.
*/
public void setMinIdleInstances(String minIdleInstances) {
- this.minIdleInstances = toNullIfEmptyOrWhitespace(minIdleInstances);
+ this.minIdleInstances = toNullIfEmptyOrWhitespace(minIdleInstances);
}
public String getMaxIdleInstances() {
@@ -1370,7 +1426,7 @@ public String getMaxIdleInstances() {
* Sets maxIdleInstances. Normalizes empty and null inputs to null.
*/
public void setMaxIdleInstances(String maxIdleInstances) {
- this.maxIdleInstances = toNullIfEmptyOrWhitespace(maxIdleInstances);
+ this.maxIdleInstances = toNullIfEmptyOrWhitespace(maxIdleInstances);
}
public boolean isEmpty() {
@@ -1385,7 +1441,7 @@ public String getMaxConcurrentRequests() {
* Sets maxConcurrentRequests. Normalizes empty and null inputs to null.
*/
public void setMaxConcurrentRequests(String maxConcurrentRequests) {
- this.maxConcurrentRequests = toNullIfEmptyOrWhitespace(maxConcurrentRequests);
+ this.maxConcurrentRequests = toNullIfEmptyOrWhitespace(maxConcurrentRequests);
}
public Integer getMinNumInstances() {
@@ -1502,14 +1558,26 @@ public void setTargetConcurrentRequests(Integer targetConcurrentRequests) {
@Override
public int hashCode() {
- return Objects.hash(maxPendingLatency, minPendingLatency, maxIdleInstances,
- minIdleInstances, maxConcurrentRequests, minNumInstances,
- maxNumInstances, coolDownPeriodSec, cpuUtilization,
- targetNetworkSentBytesPerSec, targetNetworkSentPacketsPerSec,
- targetNetworkReceivedBytesPerSec, targetNetworkReceivedPacketsPerSec,
- targetDiskWriteBytesPerSec, targetDiskWriteOpsPerSec,
- targetDiskReadBytesPerSec, targetDiskReadOpsPerSec,
- targetRequestCountPerSec, targetConcurrentRequests);
+ return Objects.hash(
+ maxPendingLatency,
+ minPendingLatency,
+ maxIdleInstances,
+ minIdleInstances,
+ maxConcurrentRequests,
+ minNumInstances,
+ maxNumInstances,
+ coolDownPeriodSec,
+ cpuUtilization,
+ targetNetworkSentBytesPerSec,
+ targetNetworkSentPacketsPerSec,
+ targetNetworkReceivedBytesPerSec,
+ targetNetworkReceivedPacketsPerSec,
+ targetDiskWriteBytesPerSec,
+ targetDiskWriteOpsPerSec,
+ targetDiskReadBytesPerSec,
+ targetDiskReadOpsPerSec,
+ targetRequestCountPerSec,
+ targetConcurrentRequests);
}
@Override
@@ -1535,10 +1603,10 @@ public boolean equals(Object obj) {
&& Objects.equals(cpuUtilization, other.cpuUtilization)
&& Objects.equals(targetNetworkSentBytesPerSec, other.targetNetworkSentBytesPerSec)
&& Objects.equals(targetNetworkSentPacketsPerSec, other.targetNetworkSentPacketsPerSec)
- && Objects.equals(targetNetworkReceivedBytesPerSec,
- other.targetNetworkReceivedBytesPerSec)
- && Objects.equals(targetNetworkReceivedPacketsPerSec,
- other.targetNetworkReceivedPacketsPerSec)
+ && Objects.equals(
+ targetNetworkReceivedBytesPerSec, other.targetNetworkReceivedBytesPerSec)
+ && Objects.equals(
+ targetNetworkReceivedPacketsPerSec, other.targetNetworkReceivedPacketsPerSec)
&& Objects.equals(targetDiskWriteBytesPerSec, other.targetDiskWriteBytesPerSec)
&& Objects.equals(targetDiskWriteOpsPerSec, other.targetDiskWriteOpsPerSec)
&& Objects.equals(targetDiskReadBytesPerSec, other.targetDiskReadBytesPerSec)
@@ -1549,25 +1617,44 @@ public boolean equals(Object obj) {
@Override
public String toString() {
- return "AutomaticScaling [minPendingLatency=" + minPendingLatency
- + ", maxPendingLatency=" + maxPendingLatency
- + ", minIdleInstances=" + minIdleInstances
- + ", maxIdleInstances=" + maxIdleInstances
- + ", maxConcurrentRequests=" + maxConcurrentRequests
- + ", minNumInstances=" + minNumInstances
- + ", maxNumInstances=" + maxNumInstances
- + ", coolDownPeriodSec=" + coolDownPeriodSec
- + ", cpuUtilization=" + cpuUtilization
- + ", targetNetworkSentBytesPerSec=" + targetNetworkSentBytesPerSec
- + ", targetNetworkSentPacketsPerSec=" + targetNetworkSentPacketsPerSec
- + ", targetNetworkReceivedBytesPerSec=" + targetNetworkReceivedBytesPerSec
- + ", targetNetworkReceivedPacketsPerSec=" + targetNetworkReceivedPacketsPerSec
- + ", targetDiskWriteBytesPerSec=" + targetDiskWriteBytesPerSec
- + ", targetDiskWriteOpsPerSec=" + targetDiskWriteOpsPerSec
- + ", targetDiskReadBytesPerSec=" + targetDiskReadBytesPerSec
- + ", targetDiskReadOpsPerSec=" + targetDiskReadOpsPerSec
- + ", targetRequestCountPerSec=" + targetRequestCountPerSec
- + ", targetConcurrentRequests=" + targetConcurrentRequests
+ return "AutomaticScaling [minPendingLatency="
+ + minPendingLatency
+ + ", maxPendingLatency="
+ + maxPendingLatency
+ + ", minIdleInstances="
+ + minIdleInstances
+ + ", maxIdleInstances="
+ + maxIdleInstances
+ + ", maxConcurrentRequests="
+ + maxConcurrentRequests
+ + ", minNumInstances="
+ + minNumInstances
+ + ", maxNumInstances="
+ + maxNumInstances
+ + ", coolDownPeriodSec="
+ + coolDownPeriodSec
+ + ", cpuUtilization="
+ + cpuUtilization
+ + ", targetNetworkSentBytesPerSec="
+ + targetNetworkSentBytesPerSec
+ + ", targetNetworkSentPacketsPerSec="
+ + targetNetworkSentPacketsPerSec
+ + ", targetNetworkReceivedBytesPerSec="
+ + targetNetworkReceivedBytesPerSec
+ + ", targetNetworkReceivedPacketsPerSec="
+ + targetNetworkReceivedPacketsPerSec
+ + ", targetDiskWriteBytesPerSec="
+ + targetDiskWriteBytesPerSec
+ + ", targetDiskWriteOpsPerSec="
+ + targetDiskWriteOpsPerSec
+ + ", targetDiskReadBytesPerSec="
+ + targetDiskReadBytesPerSec
+ + ", targetDiskReadOpsPerSec="
+ + targetDiskReadOpsPerSec
+ + ", targetRequestCountPerSec="
+ + targetRequestCountPerSec
+ + ", targetConcurrentRequests="
+ + targetConcurrentRequests
+ "]";
}
}
@@ -1577,7 +1664,7 @@ public String toString() {
*/
public static class CpuUtilization {
private static final CpuUtilization EMPTY_SETTINGS = new CpuUtilization();
- // The target of CPU utilization.
+ // The target of CPU utilization.
private Double targetUtilization;
// The number of seconds used to aggregate CPU usage.
private Integer aggregationWindowLengthSec;
@@ -1585,23 +1672,23 @@ public static class CpuUtilization {
public Double getTargetUtilization() {
return targetUtilization;
}
-
+
public void setTargetUtilization(Double targetUtilization) {
this.targetUtilization = targetUtilization;
}
-
+
public Integer getAggregationWindowLengthSec() {
return aggregationWindowLengthSec;
}
-
+
public void setAggregationWindowLengthSec(Integer aggregationWindowLengthSec) {
this.aggregationWindowLengthSec = aggregationWindowLengthSec;
}
-
+
public boolean isEmpty() {
return this.equals(EMPTY_SETTINGS);
}
-
+
@Override
public int hashCode() {
return Objects.hash(targetUtilization, aggregationWindowLengthSec);
@@ -1625,8 +1712,11 @@ public boolean equals(Object obj) {
@Override
public String toString() {
- return "CpuUtilization [targetUtilization=" + targetUtilization
- + ", aggregationWindowLengthSec=" + aggregationWindowLengthSec + "]";
+ return "CpuUtilization [targetUtilization="
+ + targetUtilization
+ + ", aggregationWindowLengthSec="
+ + aggregationWindowLengthSec
+ + "]";
}
}
@@ -1698,7 +1788,6 @@ public Integer getHealthyThreshold() {
/**
* Sets healthyThreshold.
*/
-
public void setHealthyThreshold(Integer healthyThreshold) {
this.healthyThreshold = healthyThreshold;
}
@@ -1731,8 +1820,14 @@ public boolean isEmpty() {
@Override
public int hashCode() {
- return Objects.hash(enableHealthCheck, checkIntervalSec, timeoutSec, unhealthyThreshold,
- healthyThreshold, restartThreshold, host);
+ return Objects.hash(
+ enableHealthCheck,
+ checkIntervalSec,
+ timeoutSec,
+ unhealthyThreshold,
+ healthyThreshold,
+ restartThreshold,
+ host);
}
@Override
@@ -1758,13 +1853,21 @@ public boolean equals(Object obj) {
@Override
public String toString() {
- return "HealthCheck [enableHealthCheck=" + enableHealthCheck
- + ", checkIntervalSec=" + checkIntervalSec
- + ", timeoutSec=" + timeoutSec
- + ", unhealthyThreshold=" + unhealthyThreshold
- + ", healthyThreshold=" + healthyThreshold
- + ", restartThreshold=" + restartThreshold
- + ", host=" + host + "]";
+ return "HealthCheck [enableHealthCheck="
+ + enableHealthCheck
+ + ", checkIntervalSec="
+ + checkIntervalSec
+ + ", timeoutSec="
+ + timeoutSec
+ + ", unhealthyThreshold="
+ + unhealthyThreshold
+ + ", healthyThreshold="
+ + healthyThreshold
+ + ", restartThreshold="
+ + restartThreshold
+ + ", host="
+ + host
+ + "]";
}
}
@@ -1830,16 +1933,21 @@ public boolean equals(Object obj) {
return false;
}
Resources other = (Resources) obj;
- return Objects.equals(cpu, other.cpu) &&
- Objects.equals(memory_gb, other.memory_gb) &&
- Objects.equals(disk_size_gb, other.disk_size_gb);
+ return Objects.equals(cpu, other.cpu)
+ && Objects.equals(memory_gb, other.memory_gb)
+ && Objects.equals(disk_size_gb, other.disk_size_gb);
}
@Override
public String toString() {
- return "Resources [" + "cpu=" + cpu +
- ", memory_gb=" + memory_gb +
- ", disk_size_gb=" + disk_size_gb + "]";
+ return "Resources ["
+ + "cpu="
+ + cpu
+ + ", memory_gb="
+ + memory_gb
+ + ", disk_size_gb="
+ + disk_size_gb
+ + "]";
}
}
@@ -2032,8 +2140,12 @@ public boolean equals(Object obj) {
@Override
public String toString() {
- return "BasicScaling [" + "maxInstances=" + maxInstances
- + ", idleTimeout=" + idleTimeout + "]";
+ return "BasicScaling ["
+ + "maxInstances="
+ + maxInstances
+ + ", idleTimeout="
+ + idleTimeout
+ + "]";
}
}
@@ -2060,13 +2172,23 @@ public int hashCode() {
// Generated by eclipse.
@Override
public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
ClassLoaderConfig other = (ClassLoaderConfig) obj;
if (entries == null) {
- if (other.entries != null) return false;
- } else if (!entries.equals(other.entries)) return false;
+ if (other.entries != null) {
+ return false;
+ }
+ } else if (!entries.equals(other.entries)) {
+ return false;
+ }
return true;
}
@@ -2078,12 +2200,13 @@ public String toString() {
public static class PrioritySpecifierEntry {
private String filename;
- private Double priority; // null means not present. Default priority is 1.0.
+ private Double priority; // null means not present. Default priority is 1.0.
private void checkNotAlreadySet() {
if (filename != null) {
- throw new AppEngineConfigException("Found more that one file name matching tag. "
- + "Only one of 'filename' attribute allowed.");
+ throw new AppEngineConfigException(
+ "Found more that one file name matching tag. "
+ + "Only one of 'filename' attribute allowed.");
}
}
@@ -2142,16 +2265,30 @@ public int hashCode() {
// Generated by eclipse.
@Override
public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
PrioritySpecifierEntry other = (PrioritySpecifierEntry) obj;
if (filename == null) {
- if (other.filename != null) return false;
- } else if (!filename.equals(other.filename)) return false;
+ if (other.filename != null) {
+ return false;
+ }
+ } else if (!filename.equals(other.filename)) {
+ return false;
+ }
if (priority == null) {
- if (other.priority != null) return false;
- } else if (!priority.equals(other.priority)) return false;
+ if (other.priority != null) {
+ return false;
+ }
+ } else if (!priority.equals(other.priority)) {
+ return false;
+ }
return true;
}
@@ -2160,4 +2297,4 @@ public String toString() {
return "PrioritySpecifierEntry{filename=\"" + filename + "\", priority=\"" + priority + "\"}";
}
}
-}
\ No newline at end of file
+}
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlProcessor.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlProcessor.java
index b58a281..458b3b0 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlProcessor.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlProcessor.java
@@ -1,19 +1,18 @@
/**
* Copyright 2008 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.config;
import com.google.apphosting.utils.config.AppEngineWebXml.AdminConsolePage;
@@ -46,7 +45,10 @@
*/
class AppEngineWebXmlProcessor {
- enum FileType { STATIC, RESOURCE }
+ enum FileType {
+ STATIC,
+ RESOURCE
+ }
// Error handling to disallow having both module and service entries.
private boolean moduleNodeFound;
@@ -95,8 +97,8 @@ private static void checkScalingConstraints(AppEngineWebXml appEngineWebXml) {
count += appEngineWebXml.getAutomaticScaling().isEmpty() ? 0 : 1;
if (count > 1) {
throw new AppEngineConfigException(
- "There may be only one of 'automatic-scaling', 'manual-scaling' or " +
- "'basic-scaling' elements.");
+ "There may be only one of 'automatic-scaling', 'manual-scaling' or "
+ + "'basic-scaling' elements.");
}
}
@@ -253,7 +255,7 @@ private void processModuleNode(Element node, AppEngineWebXml appEngineWebXml) {
private void processServiceNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setService(getTextNode(node));
}
-
+
private void processInstanceClassNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setInstanceClass(getTextNode(node));
@@ -307,6 +309,7 @@ private Double getChildNodeDouble(Element parentNode, String childTag) {
}
return result;
}
+
private void processAutomaticScalingNode(Element settingsNode, AppEngineWebXml appEngineWebXml) {
AutomaticScaling automaticScaling = appEngineWebXml.getAutomaticScaling();
automaticScaling.setMinPendingLatency(getChildNodeText(settingsNode, "min-pending-latency"));
@@ -492,10 +495,8 @@ private void processHealthCheckNode(Element settingsNode, AppEngineWebXml appEng
healthCheck.setTimeoutSec(getChildNodePositiveInteger(settingsNode, "timeout-sec"));
healthCheck.setUnhealthyThreshold(
getChildNodePositiveInteger(settingsNode, "unhealthy-threshold"));
- healthCheck.setHealthyThreshold(
- getChildNodePositiveInteger(settingsNode, "healthy-threshold"));
- healthCheck.setRestartThreshold(
- getChildNodePositiveInteger(settingsNode, "restart-threshold"));
+ healthCheck.setHealthyThreshold(getChildNodePositiveInteger(settingsNode, "healthy-threshold"));
+ healthCheck.setRestartThreshold(getChildNodePositiveInteger(settingsNode, "restart-threshold"));
healthCheck.setHost(getChildNodeText(settingsNode, "host"));
}
@@ -598,6 +599,7 @@ private void processApiConfigNode(Element node, AppEngineWebXml appEngineWebXml)
}
}
}
+
private void processClassLoaderConfig(Element node, AppEngineWebXml appEngineWebXml) {
ClassLoaderConfig config = new ClassLoaderConfig();
appEngineWebXml.setClassLoaderConfig(config);
@@ -646,4 +648,4 @@ private String trim(String attribute) {
private void processUseGoogleConnectorJNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setUseGoogleConnectorJ(getBooleanValue(node));
}
-}
\ No newline at end of file
+}
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlReader.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlReader.java
index f2e048d..dabc109 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlReader.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/AppEngineWebXmlReader.java
@@ -1,19 +1,18 @@
/**
* Copyright 2008 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.config;
import java.io.File;
@@ -32,8 +31,7 @@
*
*/
public class AppEngineWebXmlReader {
- private static final Logger logger =
- Logger.getLogger(AppEngineWebXmlReader.class.getName());
+ private static final Logger logger = Logger.getLogger(AppEngineWebXmlReader.class.getName());
private static final String CONCURRENT_REQUESTS_URL =
"http://code.google.com/appengine/docs/java/config/appconfig.html#Using_Concurrent_Requests";
@@ -92,21 +90,30 @@ public AppEngineWebXml readAppEngineWebXml() {
if (!appEngineWebXml.getThreadsafeValueProvided()) {
if (allowMissingThreadsafeElement()) {
// make some noise if there is no element.
- logger.warning("appengine-web.xml does not contain a element. This will "
- + "be treated as an error the next time you deploy.\nSee " + CONCURRENT_REQUESTS_URL
- + " for more information.\nYou probably want to enable concurrent requests.");
+ logger.warning(
+ "appengine-web.xml does not contain a element. This will "
+ + "be treated as an error the next time you deploy.\nSee "
+ + CONCURRENT_REQUESTS_URL
+ + " for more information.\nYou probably want to enable concurrent requests.");
} else {
- throw new AppEngineConfigException("appengine-web.xml does not contain a "
- + "element.\nSee " + CONCURRENT_REQUESTS_URL + " for more information.\nYou probably "
- + "want to enable concurrent requests.");
+ throw new AppEngineConfigException(
+ "appengine-web.xml does not contain a "
+ + "element.\nSee "
+ + CONCURRENT_REQUESTS_URL
+ + " for more information.\nYou probably "
+ + "want to enable concurrent requests.");
}
}
if ("legacy".equals(appEngineWebXml.getAutoIdPolicy())) {
- logger.warning("You have set the datastore auto id policy to 'legacy'. It is recommended "
- + "that you select 'default' instead.\nLegacy auto ids are deprecated. You can "
- + "continue to allocate legacy ids manually using the allocateIds() API functions.\n"
- + "For more information see:\n"
- + APPCFG_AUTO_IDS_URL + "\n" + DATASTORE_AUTO_IDS_URL + "\n");
+ logger.warning(
+ "You have set the datastore auto id policy to 'legacy'. It is recommended "
+ + "that you select 'default' instead.\nLegacy auto ids are deprecated. You can "
+ + "continue to allocate legacy ids manually using the allocateIds() API functions.\n"
+ + "For more information see:\n"
+ + APPCFG_AUTO_IDS_URL
+ + "\n"
+ + DATASTORE_AUTO_IDS_URL
+ + "\n");
}
} catch (Exception e) {
String msg = "Received exception processing " + getFilename();
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/XmlUtils.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/XmlUtils.java
index 88a69d9..cc8c37b 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/XmlUtils.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/config/XmlUtils.java
@@ -1,19 +1,18 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.config;
import com.google.appengine.repackaged.com.google.common.io.Files;
@@ -73,8 +72,9 @@ static Document parseXml(InputStream inputStream, String filename) {
String msg = "Received SAXException parsing the input stream" + maybeFilename(filename);
throw new AppEngineConfigException(msg, e);
} catch (ParserConfigurationException e) {
- String msg = "Received ParserConfigurationException parsing the input stream"
- + maybeFilename(filename);
+ String msg =
+ "Received ParserConfigurationException parsing the input stream"
+ + maybeFilename(filename);
throw new AppEngineConfigException(msg, e);
}
}
@@ -129,8 +129,9 @@ static void validateXmlContent(String content, File schema) {
factory
.newSchema(schema)
.newValidator()
- .validate(new StreamSource(new ByteArrayInputStream(
- content.getBytes(StandardCharsets.UTF_8))));
+ .validate(
+ new StreamSource(
+ new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))));
} catch (SAXException ex) {
throw new AppEngineConfigException(
"XML error validating " + content + " against " + schema.getPath(), ex);
@@ -216,4 +217,4 @@ static List getChildren(Element element, String tagName) {
}
return elements;
}
-}
\ No newline at end of file
+}
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpRequest.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpRequest.java
index 1828a3e..856353f 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpRequest.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpRequest.java
@@ -1,19 +1,18 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.http;
/**
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpResponse.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpResponse.java
index 408c944..0b4311a 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpResponse.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/http/HttpResponse.java
@@ -1,19 +1,18 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.http;
import java.io.IOException;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/DeferredTaskServlet.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/DeferredTaskServlet.java
index d9b0dd2..08dd5e0 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/DeferredTaskServlet.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/DeferredTaskServlet.java
@@ -1,20 +1,18 @@
/**
* Copyright 2011 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.utils.servlet;
import com.google.appengine.api.taskqueue.DeferredTask;
@@ -60,15 +58,14 @@ public class DeferredTaskServlet extends HttpServlet {
static final String X_APPENGINE_QUEUENAME = "X-AppEngine-QueueName";
static final String DEFERRED_TASK_SERVLET_KEY =
- DeferredTaskContext.class.getName() + ".httpServlet";
+ DeferredTaskContext.class.getName() + ".httpServlet";
static final String DEFERRED_TASK_REQUEST_KEY =
- DeferredTaskContext.class.getName() + ".httpServletRequest";
+ DeferredTaskContext.class.getName() + ".httpServletRequest";
static final String DEFERRED_TASK_RESPONSE_KEY =
- DeferredTaskContext.class.getName() + ".httpServletResponse";
+ DeferredTaskContext.class.getName() + ".httpServletResponse";
static final String DEFERRED_DO_NOT_RETRY_KEY =
- DeferredTaskContext.class.getName() + ".doNotRetry";
- static final String DEFERRED_MARK_RETRY_KEY =
- DeferredTaskContext.class.getName() + ".markRetry";
+ DeferredTaskContext.class.getName() + ".doNotRetry";
+ static final String DEFERRED_MARK_RETRY_KEY = DeferredTaskContext.class.getName() + ".markRetry";
/**
* Thrown by readRequest when an error occurred during deserialization.
@@ -94,9 +91,9 @@ protected void service(HttpServletRequest req, HttpServletResponse resp)
String protocol = req.getProtocol();
String msg = "DeferredTaskServlet does not support method: " + method;
if (protocol.endsWith("1.1")) {
- resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
} else {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
}
return;
}
@@ -125,9 +122,11 @@ protected void service(HttpServletRequest req, HttpServletResponse resp)
if (doNotRetry == null || !doNotRetry) {
throw new ServletException(e);
} else if (doNotRetry) {
- resp.setStatus(HttpURLConnection.HTTP_NOT_AUTHORITATIVE); // Alternate success code.
- log(DeferredTaskServlet.class.getName() +
- " - Deferred task failed but doNotRetry specified. Exception: " + e);
+ resp.setStatus(HttpURLConnection.HTTP_NOT_AUTHORITATIVE); // Alternate success code.
+ log(
+ DeferredTaskServlet.class.getName()
+ + " - Deferred task failed but doNotRetry specified. Exception: "
+ + e);
}
} finally {
// Clean out the attributes.
@@ -149,8 +148,8 @@ protected void service(HttpServletRequest req, HttpServletResponse resp)
* Note that other exceptions may be thrown by the
* {@link DeferredTask#run()} method.
*/
- protected void performRequest(
- HttpServletRequest req, HttpServletResponse resp) throws DeferredTaskException {
+ protected void performRequest(HttpServletRequest req, HttpServletResponse resp)
+ throws DeferredTaskException {
readRequest(req, resp).run();
}
@@ -165,68 +164,74 @@ protected void performRequest(
*
{@link IOException}: Deserialization failure.
* {@link ClassCastException}: Deserialization failure. *
*/
- protected DeferredTask readRequest(
- HttpServletRequest req, HttpServletResponse resp) throws DeferredTaskException {
+ protected DeferredTask readRequest(HttpServletRequest req, HttpServletResponse resp)
+ throws DeferredTaskException {
String contentType = req.getHeader("content-type");
- if (contentType == null ||
- !contentType.equals(DeferredTaskContext.RUNNABLE_TASK_CONTENT_TYPE)) {
- throw new DeferredTaskException(new IllegalArgumentException(
- "Invalid content-type header."
- + " received: '" + (contentType == null ? "null" : contentType)
- + "' expected: '" + DeferredTaskContext.RUNNABLE_TASK_CONTENT_TYPE + "'"));
+ if (contentType == null
+ || !contentType.equals(DeferredTaskContext.RUNNABLE_TASK_CONTENT_TYPE)) {
+ throw new DeferredTaskException(
+ new IllegalArgumentException(
+ "Invalid content-type header."
+ + " received: '"
+ + (contentType == null ? "null" : contentType)
+ + "' expected: '"
+ + DeferredTaskContext.RUNNABLE_TASK_CONTENT_TYPE
+ + "'"));
}
DeferredTask deferredTask;
try {
ServletInputStream stream = req.getInputStream();
- ObjectInputStream objectStream = new ObjectInputStream(stream) {
- @Override
- protected Class> resolveClass(ObjectStreamClass desc) throws IOException,
- ClassNotFoundException {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- String name = desc.getName();
- try {
- return Class.forName(name, false, classLoader);
- } catch (ClassNotFoundException ex) {
- // This one should also handle primitive types
- return super.resolveClass(desc);
- }
- }
-
- @Override
- protected Class> resolveProxyClass(String[] interfaces)
- throws IOException, ClassNotFoundException {
- // Note(user) This logic was copied from ObjectInputStream.java in the
- // JDK, and then modified to use the thread context class loader instead of the
- // "latest" loader that is used there.
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader nonPublicLoader = null;
- boolean hasNonPublicInterface = false;
+ ObjectInputStream objectStream =
+ new ObjectInputStream(stream) {
+ @Override
+ protected Class> resolveClass(ObjectStreamClass desc)
+ throws IOException, ClassNotFoundException {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ String name = desc.getName();
+ try {
+ return Class.forName(name, false, classLoader);
+ } catch (ClassNotFoundException ex) {
+ // This one should also handle primitive types
+ return super.resolveClass(desc);
+ }
+ }
- // define proxy in class loader of non-public interface(s), if any
- Class[] classObjs = new Class[interfaces.length];
- for (int i = 0; i < interfaces.length; i++) {
- Class cl = Class.forName(interfaces[i], false, classLoader);
- if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
- if (hasNonPublicInterface) {
- if (nonPublicLoader != cl.getClassLoader()) {
- throw new IllegalAccessError("conflicting non-public interface class loaders");
+ @Override
+ protected Class> resolveProxyClass(String[] interfaces)
+ throws IOException, ClassNotFoundException {
+ // Note(user) This logic was copied from ObjectInputStream.java in the
+ // JDK, and then modified to use the thread context class loader instead of the
+ // "latest" loader that is used there.
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader nonPublicLoader = null;
+ boolean hasNonPublicInterface = false;
+
+ // define proxy in class loader of non-public interface(s), if any
+ Class[] classObjs = new Class[interfaces.length];
+ for (int i = 0; i < interfaces.length; i++) {
+ Class cl = Class.forName(interfaces[i], false, classLoader);
+ if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
+ if (hasNonPublicInterface) {
+ if (nonPublicLoader != cl.getClassLoader()) {
+ throw new IllegalAccessError(
+ "conflicting non-public interface class loaders");
+ }
+ } else {
+ nonPublicLoader = cl.getClassLoader();
+ hasNonPublicInterface = true;
+ }
}
- } else {
- nonPublicLoader = cl.getClassLoader();
- hasNonPublicInterface = true;
+ classObjs[i] = cl;
+ }
+ try {
+ return Proxy.getProxyClass(
+ hasNonPublicInterface ? nonPublicLoader : classLoader, classObjs);
+ } catch (IllegalArgumentException e) {
+ throw new ClassNotFoundException(null, e);
}
}
- classObjs[i] = cl;
- }
- try {
- return Proxy.getProxyClass(
- hasNonPublicInterface ? nonPublicLoader : classLoader, classObjs);
- } catch (IllegalArgumentException e) {
- throw new ClassNotFoundException(null, e);
- }
- }
- };
+ };
deferredTask = (DeferredTask) objectStream.readObject();
} catch (ClassNotFoundException e) {
throw new DeferredTaskException(e);
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletRequestAdapter.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletRequestAdapter.java
index 50a59c7..8dcf6d9 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletRequestAdapter.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletRequestAdapter.java
@@ -1,19 +1,18 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.servlet;
import com.google.apphosting.utils.http.HttpRequest;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletResponseAdapter.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletResponseAdapter.java
index d668bd8..cbf447f 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletResponseAdapter.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/HttpServletResponseAdapter.java
@@ -1,19 +1,18 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.servlet;
import com.google.apphosting.utils.http.HttpResponse;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/MultipartMimeUtils.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/MultipartMimeUtils.java
index 7873a88..bee57fa 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/MultipartMimeUtils.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/MultipartMimeUtils.java
@@ -1,20 +1,18 @@
/**
* Copyright 2009 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.utils.servlet;
import com.google.appengine.repackaged.com.google.common.io.ByteStreams;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/ParseBlobUploadFilter.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/ParseBlobUploadFilter.java
index b0624ec..fed1469 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/ParseBlobUploadFilter.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/ParseBlobUploadFilter.java
@@ -1,20 +1,18 @@
/**
* Copyright 2009 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.utils.servlet;
import java.io.ByteArrayInputStream;
@@ -56,8 +54,7 @@
*
*/
public class ParseBlobUploadFilter implements Filter {
- private static final Logger logger = Logger.getLogger(
- ParseBlobUploadFilter.class.getName());
+ private static final Logger logger = Logger.getLogger(ParseBlobUploadFilter.class.getName());
/**
* An arbitrary HTTP header that is set on all blob upload
@@ -80,11 +77,9 @@ public class ParseBlobUploadFilter implements Filter {
static final String CONTENT_LENGTH_HEADER = "Content-Length";
- public void init(FilterConfig config) {
- }
+ public void init(FilterConfig config) {}
- public void destroy() {
- }
+ public void destroy() {}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/SessionCleanupServlet.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/SessionCleanupServlet.java
index 8752599..186cab8 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/SessionCleanupServlet.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/SessionCleanupServlet.java
@@ -1,20 +1,18 @@
/**
* Copyright 2008 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.utils.servlet;
import com.google.appengine.api.datastore.DatastoreService;
@@ -67,11 +65,10 @@ public void service(HttpServletRequest request, HttpServletResponse response) {
private void clearAll(HttpServletResponse response) {
Query query = new Query(SESSION_ENTITY_TYPE);
query.setKeysOnly();
- query.addFilter(EXPIRES_PROP, Query.FilterOperator.LESS_THAN,
- System.currentTimeMillis());
+ query.addFilter(EXPIRES_PROP, Query.FilterOperator.LESS_THAN, System.currentTimeMillis());
ArrayList killList = new ArrayList();
- Iterable entities = datastore.prepare(query).asIterable(
- FetchOptions.Builder.withLimit(MAX_SESSION_COUNT));
+ Iterable entities =
+ datastore.prepare(query).asIterable(FetchOptions.Builder.withLimit(MAX_SESSION_COUNT));
for (Entity expiredSession : entities) {
Key key = expiredSession.getKey();
killList.add(key);
@@ -88,8 +85,7 @@ private void clearAll(HttpServletResponse response) {
private void sendForm(String actionUrl, HttpServletResponse response) {
Query query = new Query(SESSION_ENTITY_TYPE);
query.setKeysOnly();
- query.addFilter(EXPIRES_PROP, Query.FilterOperator.LESS_THAN,
- System.currentTimeMillis());
+ query.addFilter(EXPIRES_PROP, Query.FilterOperator.LESS_THAN, System.currentTimeMillis());
int count = datastore.prepare(query).countEntities();
response.setContentType("text/html");
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/TransactionCleanupFilter.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/TransactionCleanupFilter.java
index 7a6e9d0..011b54d 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/TransactionCleanupFilter.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/TransactionCleanupFilter.java
@@ -1,22 +1,20 @@
/**
* Copyright 2008 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.apphosting.utils.servlet;
-
import java.io.IOException;
import javax.servlet.FilterConfig;
@@ -31,13 +29,12 @@
*/
public class TransactionCleanupFilter implements Filter {
- public void init(FilterConfig filterConfig) {
- }
+ public void init(FilterConfig filterConfig) {}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
- chain.doFilter(request, response);
- }
- public void destroy() {
+ chain.doFilter(request, response);
}
+
+ public void destroy() {}
}
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmHealthServlet.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmHealthServlet.java
index 322b31a..aabaabd 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmHealthServlet.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmHealthServlet.java
@@ -1,20 +1,18 @@
/**
* Copyright 2013 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.utils.servlet;
import com.google.appengine.api.LifecycleManager;
@@ -41,8 +39,8 @@ private String fullVersionId() {
ApiProxy.Environment environment = ApiProxy.getCurrentEnvironment();
String actualVersionId = environment.getVersionId();
if (!(environment.getModuleId() == null
- || environment.getModuleId().isEmpty()
- || environment.getModuleId().equals("default"))) {
+ || environment.getModuleId().isEmpty()
+ || environment.getModuleId().equals("default"))) {
actualVersionId = environment.getModuleId() + ":" + actualVersionId;
}
return actualVersionId;
@@ -53,20 +51,23 @@ public void service(HttpServletRequest request, HttpServletResponse response) th
// Check if the instance is shutting down, in that case return unhealthy (lameduck).
LifecycleManager lifeCycleManager = LifecycleManager.getInstance();
if (LifecycleManager.getInstance().isShuttingDown()) {
- long remainingShutdownTime = lifeCycleManager.getRemainingShutdownTime();
- response.sendError(HttpServletResponse.SC_BAD_GATEWAY,
- "App is shutting down, time remaining: " + remainingShutdownTime + " ms");
- return;
+ long remainingShutdownTime = lifeCycleManager.getRemainingShutdownTime();
+ response.sendError(
+ HttpServletResponse.SC_BAD_GATEWAY,
+ "App is shutting down, time remaining: " + remainingShutdownTime + " ms");
+ return;
}
String expectedVersion = request.getParameter("VersionID");
String actualVersion = fullVersionId();
- if ((expectedVersion == null) || expectedVersion.equals(actualVersion)){
+ if ((expectedVersion == null) || expectedVersion.equals(actualVersion)) {
response.setContentType("text/plain");
response.getWriter().write("ok");
} else {
response.setContentType("text/plain");
- response.getWriter().write(
- String.format("version mismatch \"%s\" != \"%s\"", expectedVersion, actualVersion));
+ response
+ .getWriter()
+ .write(
+ String.format("version mismatch \"%s\" != \"%s\"", expectedVersion, actualVersion));
}
}
}
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmStopFilter.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmStopFilter.java
index 8854d43..83d3178 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmStopFilter.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/VmStopFilter.java
@@ -1,20 +1,18 @@
/**
* Copyright 2013 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.utils.servlet;
import com.google.appengine.api.LifecycleManager;
@@ -45,12 +43,10 @@ public class VmStopFilter implements Filter {
TimeUnit.SECONDS.convert(60, TimeUnit.MILLISECONDS);
@Override
- public void init(FilterConfig config) {
- }
+ public void init(FilterConfig config) {}
@Override
- public void destroy() {
- }
+ public void destroy() {}
/**
* Handle stop requests.
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/WarmupServlet.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/WarmupServlet.java
index fd277ed..60d67ca 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/WarmupServlet.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/utils/servlet/WarmupServlet.java
@@ -1,20 +1,18 @@
/**
* Copyright 2010 Google Inc. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.utils.servlet;
import java.io.IOException;
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/RPCFailedStatusException.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/RPCFailedStatusException.java
index c564db2..5f87c41 100644
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/RPCFailedStatusException.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/RPCFailedStatusException.java
@@ -3,14 +3,14 @@
import com.google.apphosting.api.ApiProxy;
public class RPCFailedStatusException extends ApiProxy.RPCFailedException {
- private final int statusCode;
+ private final int statusCode;
- public RPCFailedStatusException(String packageName, String methodName, int statusCode) {
- super(packageName, methodName);
- this.statusCode = statusCode;
- }
+ public RPCFailedStatusException(String packageName, String methodName, int statusCode) {
+ super(packageName, methodName);
+ this.statusCode = statusCode;
+ }
- public int getStatusCode() {
- return statusCode;
- }
+ public int getStatusCode() {
+ return statusCode;
+ }
}
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyDelegate.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyDelegate.java
index 97c59fe..f88cd42 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyDelegate.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyDelegate.java
@@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.vmruntime;
import com.google.appengine.api.appidentity.AppIdentityServiceFailureException;
@@ -36,7 +34,6 @@
import com.google.apphosting.api.ApiProxy.LogRecord;
import com.google.apphosting.api.ApiProxy.RPCFailedException;
import com.google.apphosting.api.UserServicePb.CreateLoginURLResponse;
-import com.google.apphosting.api.UserServicePb.CreateLogoutURLRequest;
import com.google.apphosting.api.UserServicePb.CreateLogoutURLResponse;
import com.google.apphosting.utils.remoteapi.RemoteApiPb;
@@ -117,7 +114,6 @@ public VmApiProxyDelegate() {
this(new DefaultHttpClient(createConnectionManager()));
}
-
VmApiProxyDelegate(HttpClient httpclient) {
this.defaultTimeoutMs = DEFAULT_RPC_TIMEOUT_MS;
this.executor = Executors.newCachedThreadPool();
@@ -128,99 +124,144 @@ public VmApiProxyDelegate() {
@Override
public byte[] makeSyncCall(
- VmApiProxyEnvironment environment,
- String packageName,
- String methodName,
- byte[] requestData)
+ VmApiProxyEnvironment environment, String packageName, String methodName, byte[] requestData)
throws ApiProxyException {
- return makeSyncCallWithTimeout(environment, packageName, methodName, requestData,
- defaultTimeoutMs);
+ return makeSyncCallWithTimeout(
+ environment, packageName, methodName, requestData, defaultTimeoutMs);
}
private byte[] makeSyncCallWithTimeout(
- VmApiProxyEnvironment environment,
- String packageName,
- String methodName,
- byte[] requestData,
- int timeoutMs)
- throws ApiProxyException {
+ VmApiProxyEnvironment environment,
+ String packageName,
+ String methodName,
+ byte[] requestData,
+ int timeoutMs)
+ throws ApiProxyException {
return makeApiCall(environment, packageName, methodName, requestData, timeoutMs, false);
}
- private byte[] makeApiCall(VmApiProxyEnvironment environment,
+ private byte[] makeApiCall(
+ VmApiProxyEnvironment environment,
String packageName,
String methodName,
byte[] requestData,
int timeoutMs,
boolean wasAsync) {
-
+
// If this was caused by an async call we need to return the pending call semaphore.
long start = System.currentTimeMillis();
environment.apiCallStarted(VmRuntimeUtils.MAX_USER_API_CALL_WAIT_MS, wasAsync);
-
+
try {
- byte responseData[] = runSyncCall(environment, packageName, methodName, requestData, timeoutMs);
+ byte responseData[] =
+ runSyncCall(environment, packageName, methodName, requestData, timeoutMs);
long end = System.currentTimeMillis();
if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE, String.format(
- "Service bridge API call to package: %s, call: %s, of size: %s " +
- "complete. Service bridge status code: %s; response " +
- "content-length: %s. Took %s ms.", packageName, methodName, requestData.length, 200,
- responseData.length, (end - start)));
+ logger.log(
+ Level.FINE,
+ String.format(
+ "Service bridge API call to package: %s, call: %s, of size: %s "
+ + "complete. Service bridge status code: %s; response "
+ + "content-length: %s. Took %s ms.",
+ packageName,
+ methodName,
+ requestData.length,
+ 200,
+ responseData.length,
+ (end - start)));
}
-
+
// TODO Remove HACK TO FIX USER_SERVICE ISSUE #164
// Disable with -DUserServiceLocalSchemeHost=false
if ("user".equals(packageName)) {
String userservicelocal = System.getProperty("UserServiceLocalSchemeHost");
String host = (String) environment.getAttributes().get("com.google.appengine.runtime.host");
- String https = (String) environment.getAttributes().get("com.google.appengine.runtime.https");
- if ((userservicelocal==null || Boolean.valueOf(userservicelocal))
- && host != null && host.length() > 0
- && https!=null && https.length() > 0) {
+ String https =
+ (String) environment.getAttributes().get("com.google.appengine.runtime.https");
+ if ((userservicelocal == null || Boolean.valueOf(userservicelocal))
+ && host != null
+ && host.length() > 0
+ && https != null
+ && https.length() > 0) {
try {
if ("CreateLogoutURL".equals(methodName)) {
CreateLogoutURLResponse response = new CreateLogoutURLResponse();
response.parseFrom(responseData);
URI uri = new URI(response.getLogoutUrl());
- String query=uri.getQuery().replaceAll("https?://[^/]*\\.appspot\\.com", ("on".equalsIgnoreCase(https) ? "https://" : "http://")+host);
- response.setLogoutUrl(new URI("on".equalsIgnoreCase(https) ? "https" : "http", uri.getUserInfo(), host,
- uri.getPort(), uri.getPath(), query, uri.getFragment()).toASCIIString());
+ String query =
+ uri.getQuery()
+ .replaceAll(
+ "https?://[^/]*\\.appspot\\.com",
+ ("on".equalsIgnoreCase(https) ? "https://" : "http://") + host);
+ response.setLogoutUrl(
+ new URI(
+ "on".equalsIgnoreCase(https) ? "https" : "http",
+ uri.getUserInfo(),
+ host,
+ uri.getPort(),
+ uri.getPath(),
+ query,
+ uri.getFragment())
+ .toASCIIString());
return response.toByteArray();
}
if ("CreateLoginURL".equals(methodName)) {
CreateLoginURLResponse response = new CreateLoginURLResponse();
response.parseFrom(responseData);
URI uri = new URI(response.getLoginUrl());
- String query=uri.getQuery().replaceAll("http?://[^/]*\\.appspot\\.com", ("on".equalsIgnoreCase(https) ? "https://" : "http://")+host);
- response.setLoginUrl(new URI(uri.getScheme(),uri.getUserInfo(),uri.getHost(),
- uri.getPort(), uri.getPath(), query, uri.getFragment()).toASCIIString());
+ String query =
+ uri.getQuery()
+ .replaceAll(
+ "http?://[^/]*\\.appspot\\.com",
+ ("on".equalsIgnoreCase(https) ? "https://" : "http://") + host);
+ response.setLoginUrl(
+ new URI(
+ uri.getScheme(),
+ uri.getUserInfo(),
+ uri.getHost(),
+ uri.getPort(),
+ uri.getPath(),
+ query,
+ uri.getFragment())
+ .toASCIIString());
return response.toByteArray();
}
} catch (URISyntaxException e) {
- logger.log(Level.WARNING,"Problem adjusting UserService URI",e);
+ logger.log(Level.WARNING, "Problem adjusting UserService URI", e);
}
}
}
return responseData;
- } catch(Exception e) {
+ } catch (Exception e) {
long end = System.currentTimeMillis();
int statusCode = 200; // default
- if (e instanceof RPCFailedStatusException)
+ if (e instanceof RPCFailedStatusException) {
statusCode = ((RPCFailedStatusException) e).getStatusCode();
- logger.log(Level.WARNING, String.format(
- "Exception during service bridge API call to package: %s, call: %s, " +
- "of size: %s bytes, status code: %d. Took %s ms. %s", packageName, methodName,
- requestData.length, statusCode, (end - start), e.getClass().getSimpleName()), e);
+ }
+ logger.log(
+ Level.WARNING,
+ String.format(
+ "Exception during service bridge API call to package: %s, call: %s, "
+ + "of size: %s bytes, status code: %d. Took %s ms. %s",
+ packageName,
+ methodName,
+ requestData.length,
+ statusCode,
+ (end - start),
+ e.getClass().getSimpleName()),
+ e);
throw e;
} finally {
environment.apiCallCompleted();
}
}
-
- protected byte[] runSyncCall(VmApiProxyEnvironment environment, String packageName,
- String methodName, byte[] requestData, int timeoutMs) {
+ protected byte[] runSyncCall(
+ VmApiProxyEnvironment environment,
+ String packageName,
+ String methodName,
+ byte[] requestData,
+ int timeoutMs) {
HttpPost request = createRequest(environment, packageName, methodName, requestData, timeoutMs);
try {
// Create a new http context for each call as the default context is not thread safe.
@@ -230,9 +271,10 @@ protected byte[] runSyncCall(VmApiProxyEnvironment environment, String packageNa
// Check for HTTP error status and return early.
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
try (Scanner errorStreamScanner =
- new Scanner(new BufferedInputStream(response.getEntity().getContent()));) {
+ new Scanner(new BufferedInputStream(response.getEntity().getContent())); ) {
logger.warning("Error body: " + errorStreamScanner.useDelimiter("\\Z").next());
- throw new RPCFailedStatusException(packageName, methodName, response.getStatusLine().getStatusCode());
+ throw new RPCFailedStatusException(
+ packageName, methodName, response.getStatusLine().getStatusCode());
}
}
try (BufferedInputStream bis = new BufferedInputStream(response.getEntity().getContent())) {
@@ -320,8 +362,12 @@ RuntimeException constructApiException(String packageName, String methodName) {
* @return an HttpPost object to send to the API.
*/
//
- static HttpPost createRequest(VmApiProxyEnvironment environment, String packageName,
- String methodName, byte[] requestData, int timeoutMs) {
+ static HttpPost createRequest(
+ VmApiProxyEnvironment environment,
+ String packageName,
+ String methodName,
+ byte[] requestData,
+ int timeoutMs) {
// Wrap the payload in a RemoteApi Request.
RemoteApiPb.Request remoteRequest = new RemoteApiPb.Request();
remoteRequest.setServiceName(packageName);
@@ -335,12 +381,12 @@ static HttpPost createRequest(VmApiProxyEnvironment environment, String packageN
// Set TCP connection timeouts.
HttpParams params = new BasicHttpParams();
- params.setLongParameter(ConnManagerPNames.TIMEOUT,
- timeoutMs + ADDITIONAL_HTTP_TIMEOUT_BUFFER_MS);
- params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
- timeoutMs + ADDITIONAL_HTTP_TIMEOUT_BUFFER_MS);
- params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
- timeoutMs + ADDITIONAL_HTTP_TIMEOUT_BUFFER_MS);
+ params.setLongParameter(
+ ConnManagerPNames.TIMEOUT, timeoutMs + ADDITIONAL_HTTP_TIMEOUT_BUFFER_MS);
+ params.setIntParameter(
+ CoreConnectionPNames.CONNECTION_TIMEOUT, timeoutMs + ADDITIONAL_HTTP_TIMEOUT_BUFFER_MS);
+ params.setIntParameter(
+ CoreConnectionPNames.SO_TIMEOUT, timeoutMs + ADDITIONAL_HTTP_TIMEOUT_BUFFER_MS);
// Performance tweaks.
params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, Boolean.TRUE);
@@ -350,7 +396,8 @@ static HttpPost createRequest(VmApiProxyEnvironment environment, String packageN
// The request deadline can be overwritten by the environment, read deadline if available.
Double deadline = (Double) (environment.getAttributes().get(API_DEADLINE_KEY));
if (deadline == null) {
- request.setHeader(RPC_DEADLINE_HEADER,
+ request.setHeader(
+ RPC_DEADLINE_HEADER,
Double.toString(TimeUnit.SECONDS.convert(timeoutMs, TimeUnit.MILLISECONDS)));
} else {
request.setHeader(RPC_DEADLINE_HEADER, Double.toString(deadline));
@@ -358,8 +405,10 @@ static HttpPost createRequest(VmApiProxyEnvironment environment, String packageN
// If the incoming request has a dapper trace header: set it on outgoing API calls
// so they are tied to the original request.
- Object dapperHeader = environment.getAttributes()
- .get(VmApiProxyEnvironment.AttributeMapping.DAPPER_ID.attributeKey);
+ Object dapperHeader =
+ environment
+ .getAttributes()
+ .get(VmApiProxyEnvironment.AttributeMapping.DAPPER_ID.attributeKey);
if (dapperHeader instanceof String) {
request.setHeader(
VmApiProxyEnvironment.AttributeMapping.DAPPER_ID.headerKey, (String) dapperHeader);
@@ -368,16 +417,18 @@ static HttpPost createRequest(VmApiProxyEnvironment environment, String packageN
// If the incoming request has a Cloud trace header: set it on outgoing API calls
// so they are tied to the original request.
// TODO(user): For now, this uses the incoming span id - use the one from the active span.
- Object traceHeader = environment.getAttributes()
- .get(VmApiProxyEnvironment.AttributeMapping.CLOUD_TRACE_CONTEXT.attributeKey);
+ Object traceHeader =
+ environment
+ .getAttributes()
+ .get(VmApiProxyEnvironment.AttributeMapping.CLOUD_TRACE_CONTEXT.attributeKey);
if (traceHeader instanceof String) {
request.setHeader(
VmApiProxyEnvironment.AttributeMapping.CLOUD_TRACE_CONTEXT.headerKey,
(String) traceHeader);
}
- ByteArrayEntity postPayload = new ByteArrayEntity(remoteRequest.toByteArray(),
- ContentType.APPLICATION_OCTET_STREAM);
+ ByteArrayEntity postPayload =
+ new ByteArrayEntity(remoteRequest.toByteArray(), ContentType.APPLICATION_OCTET_STREAM);
postPayload.setChunked(false);
request.setEntity(postPayload);
@@ -395,14 +446,11 @@ static HttpPost createRequest(VmApiProxyEnvironment environment, String packageN
* @param logger the Logger used to create log messages.
* @return ApiProxyException
*/
- private static ApiProxyException convertRemoteError(RemoteApiPb.Response remoteResponse,
- String packageName, String methodName, Logger logger) {
+ private static ApiProxyException convertRemoteError(
+ RemoteApiPb.Response remoteResponse, String packageName, String methodName, Logger logger) {
if (remoteResponse.hasRpcError()) {
return convertApiResponseRpcErrorToException(
- remoteResponse.getRpcError(),
- packageName,
- methodName,
- logger);
+ remoteResponse.getRpcError(), packageName, methodName, logger);
}
// Otherwise it's an application error
@@ -425,14 +473,24 @@ private static ApiProxyException convertApiResponseRpcErrorToException(
int rpcCode = rpcError.getCode();
String errorDetail = rpcError.getDetail();
if (rpcCode > RemoteApiPb.RpcError.ErrorCode.values().length) {
- logger.severe("Received unrecognized error code from server: " + rpcError.getCode() +
- " details: " + errorDetail);
+ logger.severe(
+ "Received unrecognized error code from server: "
+ + rpcError.getCode()
+ + " details: "
+ + errorDetail);
return new ApiProxy.UnknownException(packageName, methodName);
}
- RemoteApiPb.RpcError.ErrorCode errorCode = RemoteApiPb.RpcError.ErrorCode.values()[
- rpcError.getCode()];
- logger.warning("RPC failed, API=" + packageName + "." + methodName + " : "
- + errorCode + " : " + errorDetail);
+ RemoteApiPb.RpcError.ErrorCode errorCode =
+ RemoteApiPb.RpcError.ErrorCode.values()[rpcError.getCode()];
+ logger.warning(
+ "RPC failed, API="
+ + packageName
+ + "."
+ + methodName
+ + " : "
+ + errorCode
+ + " : "
+ + errorDetail);
// This is very similar to apphosting/utils/runtime/ApiProxyUtils.java#convertApiError,
// which is for APIResponse. TODO(user): retire both in favor of gRPC.
@@ -445,8 +503,7 @@ private static ApiProxyException convertApiResponseRpcErrorToException(
logger.severe("Security violation: invalid request id used!");
return new ApiProxy.UnknownException(packageName, methodName);
case CAPABILITY_DISABLED:
- return new ApiProxy.CapabilityDisabledException(
- errorDetail, packageName, methodName);
+ return new ApiProxy.CapabilityDisabledException(errorDetail, packageName, methodName);
case OVER_QUOTA:
return new ApiProxy.OverQuotaException(packageName, methodName);
case REQUEST_TOO_LARGE:
@@ -458,8 +515,7 @@ private static ApiProxyException convertApiResponseRpcErrorToException(
case CANCELLED:
return new ApiProxy.CancelledException(packageName, methodName);
case FEATURE_DISABLED:
- return new ApiProxy.FeatureNotEnabledException(
- errorDetail, packageName, methodName);
+ return new ApiProxy.FeatureNotEnabledException(errorDetail, packageName, methodName);
case DEADLINE_EXCEEDED:
return new ApiProxy.ApiDeadlineExceededException(packageName, methodName);
default:
@@ -475,7 +531,8 @@ private class MakeSyncCall implements Callable {
private final byte[] requestData;
private final int timeoutMs;
- public MakeSyncCall(VmApiProxyDelegate delegate,
+ public MakeSyncCall(
+ VmApiProxyDelegate delegate,
VmApiProxyEnvironment environment,
String packageName,
String methodName,
@@ -491,29 +548,25 @@ public MakeSyncCall(VmApiProxyDelegate delegate,
@Override
public byte[] call() throws Exception {
- return delegate.makeApiCall(environment,
- packageName,
- methodName,
- requestData,
- timeoutMs,
- true);
+ return delegate.makeApiCall(
+ environment, packageName, methodName, requestData, timeoutMs, true);
}
}
@Override
public Future makeAsyncCall(
- VmApiProxyEnvironment environment,
- String packageName,
- String methodName,
- byte[] request,
- ApiConfig apiConfig) {
+ VmApiProxyEnvironment environment,
+ String packageName,
+ String methodName,
+ byte[] request,
+ ApiConfig apiConfig) {
int timeoutMs = defaultTimeoutMs;
if (apiConfig != null && apiConfig.getDeadlineInSeconds() != null) {
timeoutMs = (int) (apiConfig.getDeadlineInSeconds() * 1000);
}
environment.aSyncApiCallAdded(VmRuntimeUtils.MAX_USER_API_CALL_WAIT_MS);
- return executor.submit(new MakeSyncCall(this, environment, packageName,
- methodName, request, timeoutMs));
+ return executor.submit(
+ new MakeSyncCall(this, environment, packageName, methodName, request, timeoutMs));
}
@Override
diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java
index f3a8eb9..c3e30bd 100755
--- a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java
+++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java
@@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package com.google.apphosting.vmruntime;
import com.google.apphosting.api.ApiProxy;
@@ -23,7 +21,6 @@
import com.google.apphosting.runtime.timer.Timer;
import com.google.apphosting.utils.http.HttpRequest;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -95,27 +92,24 @@ public class VmApiProxyEnvironment implements ApiProxy.Environment {
public static final String BACKEND_ID_KEY = "com.google.appengine.backend.id";
-
public static final String INSTANCE_ID_KEY = "com.google.appengine.instance.id";
public static final String AFFINITY_KEY = "com.google.appengine.affinity";
public static final String REQUEST_THREAD_FACTORY_ATTR =
- "com.google.appengine.api.ThreadManager.REQUEST_THREAD_FACTORY";
+ "com.google.appengine.api.ThreadManager.REQUEST_THREAD_FACTORY";
public static final String BACKGROUND_THREAD_FACTORY_ATTR =
- "com.google.appengine.api.ThreadManager.BACKGROUND_THREAD_FACTORY";
+ "com.google.appengine.api.ThreadManager.BACKGROUND_THREAD_FACTORY";
// If the "X-AppEngine-Federated-Identity" header is included in the request this attribute
// should be set to the boolean true, otherwise it should be set to false.
-
public static final String IS_FEDERATED_USER_KEY =
- "com.google.appengine.api.users.UserService.is_federated_user";
+ "com.google.appengine.api.users.UserService.is_federated_user";
// If the app is trusted AND the "X-AppEngine-Trusted-IP-Request" header is "1" this attribute
// should be set the the boolean true, otherwise it should be set to false.
-
public static final String IS_TRUSTED_IP_KEY = "com.google.appengine.runtime.is_trusted_ip";
public static final String IS_TRUSTED_IP_HEADER = "X-AppEngine-Trusted-IP-Request";
@@ -142,84 +136,69 @@ public class VmApiProxyEnvironment implements ApiProxy.Environment {
*/
enum AttributeMapping {
USER_ID(
- "X-AppEngine-User-Id",
- "com.google.appengine.api.users.UserService.user_id_key",
- "", false),
+ "X-AppEngine-User-Id", "com.google.appengine.api.users.UserService.user_id_key", "", false),
USER_ORGANIZATION(
- "X-AppEngine-User-Organization",
- "com.google.appengine.api.users.UserService.user_organization",
- "", false),
+ "X-AppEngine-User-Organization",
+ "com.google.appengine.api.users.UserService.user_organization",
+ "",
+ false),
FEDERATED_IDENTITY(
- "X-AppEngine-Federated-Identity",
- "com.google.appengine.api.users.UserService.federated_identity",
- "", false),
+ "X-AppEngine-Federated-Identity",
+ "com.google.appengine.api.users.UserService.federated_identity",
+ "",
+ false),
FEDERATED_PROVIDER(
- "X-AppEngine-Federated-Provider",
- "com.google.appengine.api.users.UserService.federated_authority",
- "", false),
+ "X-AppEngine-Federated-Provider",
+ "com.google.appengine.api.users.UserService.federated_authority",
+ "",
+ false),
DATACENTER(
- "X-AppEngine-Datacenter",
- "com.google.apphosting.api.ApiProxy.datacenter",
- "", false),
+ "X-AppEngine-Datacenter", "com.google.apphosting.api.ApiProxy.datacenter", "", false),
REQUEST_ID_HASH(
- "X-AppEngine-Request-Id-Hash",
- "com.google.apphosting.api.ApiProxy.request_id_hash",
- null, false),
+ "X-AppEngine-Request-Id-Hash",
+ "com.google.apphosting.api.ApiProxy.request_id_hash",
+ null,
+ false),
REQUEST_LOG_ID(
- "X-AppEngine-Request-Log-Id",
- "com.google.appengine.runtime.request_log_id",
- null, false),
- DAPPER_ID("X-Google-DapperTraceInfo",
- "com.google.appengine.runtime.dapper_id",
- null, false),
- CLOUD_TRACE_CONTEXT("X-Cloud-Trace-Context",
- "com.google.appengine.runtime.cloud_trace_context",
- null, false),
+ "X-AppEngine-Request-Log-Id", "com.google.appengine.runtime.request_log_id", null, false),
+ DAPPER_ID("X-Google-DapperTraceInfo", "com.google.appengine.runtime.dapper_id", null, false),
+ CLOUD_TRACE_CONTEXT(
+ "X-Cloud-Trace-Context", "com.google.appengine.runtime.cloud_trace_context", null, false),
DEFAULT_VERSION_HOSTNAME(
- "X-AppEngine-Default-Version-Hostname",
- "com.google.appengine.runtime.default_version_hostname",
- null, false),
+ "X-AppEngine-Default-Version-Hostname",
+ "com.google.appengine.runtime.default_version_hostname",
+ null,
+ false),
DEFAULT_NAMESPACE_HEADER(
- "X-AppEngine-Default-Namespace",
- "com.google.appengine.api.NamespaceManager.appsNamespace",
- null, false),
+ "X-AppEngine-Default-Namespace",
+ "com.google.appengine.api.NamespaceManager.appsNamespace",
+ null,
+ false),
CURRENT_NAMESPACE_HEADER(
- "X-AppEngine-Current-Namespace",
- "com.google.appengine.api.NamespaceManager.currentNamespace",
- null, false),
+ "X-AppEngine-Current-Namespace",
+ "com.google.appengine.api.NamespaceManager.currentNamespace",
+ null,
+ false),
// ########## Trusted app attributes below. ##############
LOAS_PEER_USERNAME(
- "X-AppEngine-LOAS-Peer-Username",
- "com.google.net.base.peer.loas_peer_username",
- "", true),
- GAIA_ID(
- "X-AppEngine-Gaia-Id",
- "com.google.appengine.runtime.gaia_id",
- "", true),
+ "X-AppEngine-LOAS-Peer-Username", "com.google.net.base.peer.loas_peer_username", "", true),
+ GAIA_ID("X-AppEngine-Gaia-Id", "com.google.appengine.runtime.gaia_id", "", true),
GAIA_AUTHUSER(
- "X-AppEngine-Gaia-Authuser",
- "com.google.appengine.runtime.gaia_authuser",
- "", true),
- GAIA_SESSION(
- "X-AppEngine-Gaia-Session",
- "com.google.appengine.runtime.gaia_session",
- "", true),
+ "X-AppEngine-Gaia-Authuser", "com.google.appengine.runtime.gaia_authuser", "", true),
+ GAIA_SESSION("X-AppEngine-Gaia-Session", "com.google.appengine.runtime.gaia_session", "", true),
APPSERVER_DATACENTER(
- "X-AppEngine-Appserver-Datacenter",
- "com.google.appengine.runtime.appserver_datacenter",
- "", true),
+ "X-AppEngine-Appserver-Datacenter",
+ "com.google.appengine.runtime.appserver_datacenter",
+ "",
+ true),
APPSERVER_TASK_BNS(
- "X-AppEngine-Appserver-Task-Bns",
- "com.google.appengine.runtime.appserver_task_bns",
- "", true),
- HTTPS(
- HTTPS_HEADER,
- "com.google.appengine.runtime.https",
- "off", false),
- HOST(
- "Host",
- "com.google.appengine.runtime.host",
- null, false),;
+ "X-AppEngine-Appserver-Task-Bns",
+ "com.google.appengine.runtime.appserver_task_bns",
+ "",
+ true),
+ HTTPS(HTTPS_HEADER, "com.google.appengine.runtime.https", "off", false),
+ HOST("Host", "com.google.appengine.runtime.host", null, false),
+ ;
String headerKey;
String attributeKey;
@@ -237,7 +216,7 @@ enum AttributeMapping {
* @param trustedAppOnly If true the attribute should only be set for trusted apps.
*/
AttributeMapping(
- String headerKey, String attributeKey, Object defaultValue, boolean trustedAppOnly) {
+ String headerKey, String attributeKey, Object defaultValue, boolean trustedAppOnly) {
this.headerKey = headerKey;
this.attributeKey = attributeKey;
this.defaultValue = defaultValue;
@@ -254,8 +233,11 @@ enum AttributeMapping {
* @param cache the metadata server cache.
* @return If set the environment variable corresponding to envKey, the metadata entry otherwise.
*/
- public static String getEnvOrMetadata(Map environmentMap, VmMetadataCache cache,
- String envKey, String metadataPath) {
+ public static String getEnvOrMetadata(
+ Map environmentMap,
+ VmMetadataCache cache,
+ String envKey,
+ String metadataPath) {
String envValue = environmentMap.get(envKey);
return envValue != null ? envValue : cache.getMetadata(metadataPath);
}
@@ -269,9 +251,8 @@ public static String getEnvOrMetadata(Map environmentMap, VmMeta
* @param dftValue the default value
* @return the System property or Env variable is true
*/
- public static String getSystemPropertyOrEnv(Map environmentMap,
- String envKey,
- String dftValue) {
+ public static String getSystemPropertyOrEnv(
+ Map environmentMap, String envKey, String dftValue) {
return System.getProperty(envKey, environmentMap.getOrDefault(envKey, dftValue));
}
@@ -284,9 +265,8 @@ public static String getSystemPropertyOrEnv(Map environmentMap,
* @param dftValue the default value
* @return true if the System property or Env variable is true
*/
- public static boolean getSystemPropertyOrEnvBoolean(Map environmentMap,
- String envKey,
- boolean dftValue) {
+ public static boolean getSystemPropertyOrEnvBoolean(
+ Map environmentMap, String envKey, boolean dftValue) {
return Boolean.valueOf(getSystemPropertyOrEnv(environmentMap, envKey, valueOf(dftValue)));
}
@@ -301,12 +281,13 @@ public static boolean getSystemPropertyOrEnvBoolean(Map environm
* @param appDir the canonical folder of the application.
* @return the created Environment object which can be registered with the ApiProxy.
*/
- public static VmApiProxyEnvironment createDefaultContext(Map envMap,
- VmMetadataCache cache,
- String server,
- Timer wallTimer,
- Long millisUntilSoftDeadline,
- String appDir) {
+ public static VmApiProxyEnvironment createDefaultContext(
+ Map envMap,
+ VmMetadataCache cache,
+ String server,
+ Timer wallTimer,
+ Long millisUntilSoftDeadline,
+ String appDir) {
final String longAppId = getEnvOrMetadata(envMap, cache, LONG_APP_ID_KEY, PROJECT_ATTRIBUTE);
final String partition = getEnvOrMetadata(envMap, cache, PARTITION_KEY, PARTITION_ATTRIBUTE);
final String module = getEnvOrMetadata(envMap, cache, MODULE_NAME_KEY, BACKEND_ATTRIBUTE);
@@ -317,14 +298,15 @@ public static VmApiProxyEnvironment createDefaultContext(Map env
}
final String instance = getEnvOrMetadata(envMap, cache, INSTANCE_KEY, INSTANCE_ATTRIBUTE);
final String affinity = getEnvOrMetadata(envMap, cache, AFFINITY_ENV_KEY, AFFINITY_ATTRIBUTE);
- final String appengineHostname = getEnvOrMetadata(
- envMap, cache, APPENGINE_HOSTNAME_KEY, APPENGINE_HOSTNAME_ATTRIBUTE);
+ final String appengineHostname =
+ getEnvOrMetadata(envMap, cache, APPENGINE_HOSTNAME_KEY, APPENGINE_HOSTNAME_ATTRIBUTE);
final String ticket = null;
final String email = null;
final boolean admin = false;
final String authDomain = null;
- final boolean useMvmAgent = Boolean.parseBoolean(getEnvOrMetadata(
- envMap, cache, USE_MVM_AGENT_KEY, USE_MVM_AGENT_ATTRIBUTE));
+ final boolean useMvmAgent =
+ Boolean.parseBoolean(
+ getEnvOrMetadata(envMap, cache, USE_MVM_AGENT_KEY, USE_MVM_AGENT_ATTRIBUTE));
Map attributes = new HashMap<>();
// Fill in default attributes values.
@@ -341,9 +323,24 @@ public static VmApiProxyEnvironment createDefaultContext(Map env
attributes.put(BACKEND_ID_KEY, module);
attributes.put(INSTANCE_ID_KEY, instance);
attributes.put(AFFINITY_KEY, affinity);
- VmApiProxyEnvironment defaultEnvironment = new VmApiProxyEnvironment(server, ticket, longAppId,
- partition, module, majorVersion, minorVersion, instance, appengineHostname, email, admin,
- authDomain, useMvmAgent, wallTimer, millisUntilSoftDeadline, attributes);
+ VmApiProxyEnvironment defaultEnvironment =
+ new VmApiProxyEnvironment(
+ server,
+ ticket,
+ longAppId,
+ partition,
+ module,
+ majorVersion,
+ minorVersion,
+ instance,
+ appengineHostname,
+ email,
+ admin,
+ authDomain,
+ useMvmAgent,
+ wallTimer,
+ millisUntilSoftDeadline,
+ attributes);
// Add the thread factories required by the threading API.
attributes.put(REQUEST_THREAD_FACTORY_ATTR, new VmRequestThreadFactory(null));
// Since we register VmEnvironmentFactory with ApiProxy in VmRuntimeWebAppContext,
@@ -363,13 +360,14 @@ public static VmApiProxyEnvironment createDefaultContext(Map env
* @param millisUntilSoftDeadline optional soft deadline in milliseconds relative to 'wallTimer'.
* @return the created Environment object which can be registered with the ApiProxy.
*/
- public static VmApiProxyEnvironment createFromHeaders(Map envMap,
- VmMetadataCache cache,
- HttpRequest request,
- String server,
- Timer wallTimer,
- Long millisUntilSoftDeadline,
- VmApiProxyEnvironment defaultEnvironment) {
+ public static VmApiProxyEnvironment createFromHeaders(
+ Map envMap,
+ VmMetadataCache cache,
+ HttpRequest request,
+ String server,
+ Timer wallTimer,
+ Long millisUntilSoftDeadline,
+ VmApiProxyEnvironment defaultEnvironment) {
final String longAppId = getEnvOrMetadata(envMap, cache, LONG_APP_ID_KEY, PROJECT_ATTRIBUTE);
final String partition = getEnvOrMetadata(envMap, cache, PARTITION_KEY, PARTITION_ATTRIBUTE);
final String module = getEnvOrMetadata(envMap, cache, MODULE_NAME_KEY, BACKEND_ATTRIBUTE);
@@ -379,9 +377,10 @@ public static VmApiProxyEnvironment createFromHeaders(Map envMap
final boolean useMvmAgent = defaultEnvironment.getUseMvmAgent();
final String instance = getEnvOrMetadata(envMap, cache, INSTANCE_KEY, INSTANCE_ATTRIBUTE);
final String affinity = getEnvOrMetadata(envMap, cache, AFFINITY_ENV_KEY, AFFINITY_ATTRIBUTE);
- final String ticket = getSystemPropertyOrEnvBoolean(envMap, USE_GLOBAL_TICKET_KEY, false)
- ? null
- : request.getHeader(TICKET_HEADER);
+ final String ticket =
+ getSystemPropertyOrEnvBoolean(envMap, USE_GLOBAL_TICKET_KEY, false)
+ ? null
+ : request.getHeader(TICKET_HEADER);
final String email = request.getHeader(EMAIL_HEADER);
boolean admin = false;
String value = request.getHeader(IS_ADMIN_HEADER);
@@ -407,7 +406,7 @@ public static VmApiProxyEnvironment createFromHeaders(Map envMap
attributes.put(mapping.attributeKey, headerValue);
} else if (mapping.defaultValue != null) {
attributes.put(mapping.attributeKey, mapping.defaultValue);
- } // else: The attribute is expected to be missing if the header is not set.
+ } // else: The attribute is expected to be missing if the header is not set.
}
// Fill in the special attributes that do not fit the simple mapping model.
@@ -424,9 +423,24 @@ public static VmApiProxyEnvironment createFromHeaders(Map envMap
attributes.put(IS_TRUSTED_IP_KEY, trustedIp);
}
- VmApiProxyEnvironment requestEnvironment = new VmApiProxyEnvironment(server, ticket, longAppId,
- partition, module, majorVersion, minorVersion, instance, appengineHostname, email, admin,
- authDomain, useMvmAgent, wallTimer, millisUntilSoftDeadline, attributes);
+ VmApiProxyEnvironment requestEnvironment =
+ new VmApiProxyEnvironment(
+ server,
+ ticket,
+ longAppId,
+ partition,
+ module,
+ majorVersion,
+ minorVersion,
+ instance,
+ appengineHostname,
+ email,
+ admin,
+ authDomain,
+ useMvmAgent,
+ wallTimer,
+ millisUntilSoftDeadline,
+ attributes);
// Add the thread factories required by the threading API.
attributes.put(REQUEST_THREAD_FACTORY_ATTR, new VmRequestThreadFactory(requestEnvironment));
// Since we register VmEnvironmentFactory with ApiProxy in VmRuntimeWebAppContext,
@@ -437,7 +451,7 @@ public static VmApiProxyEnvironment createFromHeaders(Map envMap
}
private final String server;
- private volatile String ticket; // request ticket is only valid until response is committed.
+ private volatile String ticket; // request ticket is only valid until response is committed.
private volatile String globalTicket; // global ticket is always valid
private final int serverPort;
private final String partition;
@@ -454,8 +468,8 @@ public static VmApiProxyEnvironment createFromHeaders(Map envMap
private final boolean useMvmAgent;
private final Map attributes;
private ThreadLocal