diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 825256393..0888445c4 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,8 +31,13 @@ jobs: strategy: matrix: os: [ubuntu-latest] - java: [17, 21, 22, 23] - jdk: [temurin] + java: [17, 21, 23] + jdk: [temurin, liberica, zulu] + exclude: + - java: 17 + jdk: liberica + - java: 17 + jdk: zulu fail-fast: false runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index dbc7b2e88..b71f6da78 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Source code for all public APIs for com.google.appengine.api.* packages. com.google.appengine appengine-api-1.0-sdk - 2.0.31 + 2.0.33 javax.servlet @@ -89,7 +89,7 @@ Source code for all public APIs for com.google.appengine.api.* packages. com.google.appengine appengine-api-1.0-sdk - 2.0.31 + 2.0.33 jakarta.servlet @@ -188,7 +188,7 @@ Source code for remote APIs for App Engine. com.google.appengine appengine-remote-api - 2.0.31 + 2.0.33 ``` @@ -211,7 +211,7 @@ We moved `com.google.appengine.api.memcache.stdimpl` and its old dependency com.google.appengine appengine-api-legacy.jar/artifactId> - 2.0.31 + 2.0.33 ``` @@ -226,19 +226,19 @@ We moved `com.google.appengine.api.memcache.stdimpl` and its old dependency com.google.appengine appengine-testing - 2.0.31 + 2.0.33 test com.google.appengine appengine-api-stubs - 2.0.31 + 2.0.33 test com.google.appengine appengine-tools-sdk - 2.0.31 + 2.0.33 test ``` diff --git a/TRYLATESTBITSINPROD.md b/TRYLATESTBITSINPROD.md index c797dda90..1ebd40053 100644 --- a/TRYLATESTBITSINPROD.md +++ b/TRYLATESTBITSINPROD.md @@ -46,7 +46,7 @@ top of your web application and change the entrypoint to boot with these jars in ./mvnw clean install ``` -Let's assume the current build version is `2.0.32-SNAPSHOT`. +Let's assume the current build version is `2.0.34-SNAPSHOT`. See the output of the runtime deployment module which contains all the jars needed by the runtime: @@ -66,7 +66,7 @@ Add the dependency for the GAE runtime jars in your application pom.xml file: ``` - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT target/${project.artifactId}-${project.version} ... diff --git a/api/pom.xml b/api/pom.xml index 3cea2a20b..85e37020d 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT true diff --git a/api/src/main/java/com/google/appengine/spi/ServiceFactoryFactory.java b/api/src/main/java/com/google/appengine/spi/ServiceFactoryFactory.java index cc842bdba..e087c8f2e 100644 --- a/api/src/main/java/com/google/appengine/spi/ServiceFactoryFactory.java +++ b/api/src/main/java/com/google/appengine/spi/ServiceFactoryFactory.java @@ -17,8 +17,6 @@ package com.google.appengine.spi; import com.google.common.base.Preconditions; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -137,44 +135,36 @@ private static final class RuntimeRegistry { } } - /** - * Retrieves the list of factory providers from the classpath - */ + /** Retrieves the list of factory providers from the classpath */ private static List> getProvidersUsingServiceLoader() { - return AccessController.doPrivileged( - new PrivilegedAction>>() { - @Override - public List> run() { - List> result = new ArrayList>(); - - // Sandboxed applications use the classloader of this class (ServiceFactoryFactory). - // VM runtime applications use the thread context classloader (if not null) and fall - // back to - // the ServiceFactoryFactory classloader otherwise. - // - ClassLoader classLoader = null; - if (Boolean.getBoolean(USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY)) { - classLoader = Thread.currentThread().getContextClassLoader(); - } - if (classLoader == null) { - // If the classloader isn't set (or set to null). Use the classloader of this class. - classLoader = ServiceFactoryFactory.class.getClassLoader(); - } - - // Can't use parameterized types in ServiceLoader.load - // - @SuppressWarnings("rawtypes") - ServiceLoader providers = - ServiceLoader.load(FactoryProvider.class, classLoader); - - if (providers != null) { - for (FactoryProvider provider : providers) { - result.add(provider); - } - } - - return result; - } - }); + List> result = new ArrayList>(); + + // Sandboxed applications use the classloader of this class (ServiceFactoryFactory). + // VM runtime applications use the thread context classloader (if not null) and fall + // back to + // the ServiceFactoryFactory classloader otherwise. + // + ClassLoader classLoader = null; + if (Boolean.getBoolean(USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY)) { + classLoader = Thread.currentThread().getContextClassLoader(); + } + if (classLoader == null) { + // If the classloader isn't set (or set to null). Use the classloader of this class. + classLoader = ServiceFactoryFactory.class.getClassLoader(); + } + + // Can't use parameterized types in ServiceLoader.load + // + @SuppressWarnings("rawtypes") + ServiceLoader providers = + ServiceLoader.load(FactoryProvider.class, classLoader); + + if (providers != null) { + for (FactoryProvider provider : providers) { + result.add(provider); + } + } + + return result; } } diff --git a/api_dev/pom.xml b/api_dev/pom.xml index 1c05eeb17..c5e7129c8 100644 --- a/api_dev/pom.xml +++ b/api_dev/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/FileBlobStorage.java b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/FileBlobStorage.java index 55effcd3b..36f5384d2 100644 --- a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/FileBlobStorage.java +++ b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/FileBlobStorage.java @@ -24,10 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; /** * {@code FileBlobStorage} provides durable persistence of blobs by storing blob content directly to @@ -46,45 +42,17 @@ class FileBlobStorage implements BlobStorage { @Override public boolean hasBlob(final BlobKey blobKey) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Boolean run() { - return getFileForBlob(blobKey).exists(); - } - }); + return getFileForBlob(blobKey).exists(); } @Override public OutputStream storeBlob(final BlobKey blobKey) throws IOException { - try { - return AccessController.doPrivileged( - new PrivilegedExceptionAction() { - @Override - public FileOutputStream run() throws IOException { - return new FileOutputStream(getFileForBlob(blobKey)); - } - }); - } catch (PrivilegedActionException ex) { - Throwable cause = ex.getCause(); - throw (cause instanceof IOException) ? (IOException) cause : new IOException(cause); - } + return new FileOutputStream(getFileForBlob(blobKey)); } @Override public InputStream fetchBlob(final BlobKey blobKey) throws IOException { - try { - return AccessController.doPrivileged( - new PrivilegedExceptionAction() { - @Override - public FileInputStream run() throws IOException { - return new FileInputStream(getFileForBlob(blobKey)); - } - }); - } catch (PrivilegedActionException ex) { - Throwable cause = ex.getCause(); - throw (cause instanceof IOException) ? (IOException) cause : new IOException(cause); - } + return new FileInputStream(getFileForBlob(blobKey)); } @Override @@ -98,21 +66,9 @@ public void deleteBlob(final BlobKey blobKey) throws IOException { && blobInfoStorage.loadGsFileInfo(blobKey) == null) { throw new RuntimeException("Unknown blobkey: " + blobKey); } - try { - AccessController.doPrivileged( - new PrivilegedExceptionAction() { - @Override - public Void run() throws IOException { - File file = getFileForBlob(blobKey); - if (!file.delete()) { - throw new IOException("Could not delete: " + file); - } - return null; - } - }); - } catch (PrivilegedActionException ex) { - Throwable cause = ex.getCause(); - throw (cause instanceof IOException) ? (IOException) cause : new IOException(cause); + File file = getFileForBlob(blobKey); + if (!file.delete()) { + throw new IOException("Could not delete: " + file); } blobInfoStorage.deleteBlobInfo(blobKey); } diff --git a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/LocalBlobstoreService.java b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/LocalBlobstoreService.java index aa51fbef1..9656c9671 100644 --- a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/LocalBlobstoreService.java +++ b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/LocalBlobstoreService.java @@ -43,8 +43,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -157,23 +155,18 @@ public CreateUploadURLResponse createUploadURL(Status status, CreateUploadURLReq } public VoidProto deleteBlob(Status status, final DeleteBlobRequest request) { - AccessController.doPrivileged( - (PrivilegedAction) - () -> { - for (String blobKeyString : request.getBlobKeyList()) { - BlobKey blobKey = new BlobKey(blobKeyString); - if (blobStorage.hasBlob(blobKey)) { - try { - blobStorage.deleteBlob(blobKey); - } catch (IOException ex) { - logger.log(Level.WARNING, "Could not delete blob: " + blobKey, ex); - throw new ApiProxy.ApplicationException( - BlobstoreServiceError.ErrorCode.INTERNAL_ERROR_VALUE, ex.toString()); - } - } - } - return null; - }); + for (String blobKeyString : request.getBlobKeyList()) { + BlobKey blobKey = new BlobKey(blobKeyString); + if (blobStorage.hasBlob(blobKey)) { + try { + blobStorage.deleteBlob(blobKey); + } catch (IOException ex) { + logger.log(Level.WARNING, "Could not delete blob: " + blobKey, ex); + throw new ApiProxy.ApplicationException( + BlobstoreServiceError.ErrorCode.INTERNAL_ERROR_VALUE, ex.toString()); + } + } + } return VoidProto.getDefaultInstance(); } @@ -222,27 +215,21 @@ public FetchDataResponse fetchData(Status status, final FetchDataRequest request } else { // Safe to cast because index will never be above MAX_BLOB_FETCH_SIZE. final byte[] data = new byte[(int) (endIndex - request.getStartIndex() + 1)]; - AccessController.doPrivileged( - (PrivilegedAction) - () -> { - try { - boolean swallowDueToThrow = true; - InputStream stream = blobStorage.fetchBlob(blobKey); - try { - ByteStreams.skipFully(stream, request.getStartIndex()); - ByteStreams.readFully(stream, data); - swallowDueToThrow = false; - } finally { - Closeables.close(stream, swallowDueToThrow); - } - } catch (IOException ex) { - logger.log(Level.WARNING, "Could not fetch data: " + blobKey, ex); - throw new ApiProxy.ApplicationException( - BlobstoreServiceError.ErrorCode.INTERNAL_ERROR_VALUE, ex.toString()); - } - - return null; - }); + try { + boolean swallowDueToThrow = true; + InputStream stream = blobStorage.fetchBlob(blobKey); + try { + ByteStreams.skipFully(stream, request.getStartIndex()); + ByteStreams.readFully(stream, data); + swallowDueToThrow = false; + } finally { + Closeables.close(stream, swallowDueToThrow); + } + } catch (IOException ex) { + logger.log(Level.WARNING, "Could not fetch data: " + blobKey, ex); + throw new ApiProxy.ApplicationException( + BlobstoreServiceError.ErrorCode.INTERNAL_ERROR_VALUE, ex.toString()); + } response.setData(ByteString.copyFrom(data)); } diff --git a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/UploadBlobServlet.java b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/UploadBlobServlet.java index d4166529d..dbfd1b082 100644 --- a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/UploadBlobServlet.java +++ b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/UploadBlobServlet.java @@ -34,11 +34,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.security.AccessController; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.security.SecureRandom; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -126,24 +123,7 @@ public void init() throws ServletException { @Override public void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Object run() throws ServletException, IOException { - handleUpload(req, resp); - return null; - } - }); - } catch (PrivilegedActionException ex) { - Throwable cause = ex.getCause(); - if (cause instanceof ServletException) { - throw (ServletException) cause; - } else if (cause instanceof IOException) { - throw (IOException) cause; - } else { - throw new ServletException(cause); - } - } + handleUpload(req, resp); } private String getSessionId(HttpServletRequest req) { diff --git a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/ee10/UploadBlobServlet.java b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/ee10/UploadBlobServlet.java index 330109aab..28e085402 100644 --- a/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/ee10/UploadBlobServlet.java +++ b/api_dev/src/main/java/com/google/appengine/api/blobstore/dev/ee10/UploadBlobServlet.java @@ -47,11 +47,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.security.AccessController; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.security.SecureRandom; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -132,24 +129,7 @@ public void init() throws ServletException { @Override public void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Object run() throws ServletException, IOException { - handleUpload(req, resp); - return null; - } - }); - } catch (PrivilegedActionException ex) { - Throwable cause = ex.getCause(); - if (cause instanceof ServletException) { - throw (ServletException) cause; - } else if (cause instanceof IOException) { - throw (IOException) cause; - } else { - throw new ServletException(cause); - } - } + handleUpload(req, resp); } private String getSessionId(HttpServletRequest req) { diff --git a/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalCompositeIndexManager.java b/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalCompositeIndexManager.java index d019eb11c..6e9d42693 100644 --- a/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalCompositeIndexManager.java +++ b/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalCompositeIndexManager.java @@ -52,8 +52,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Writer; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -339,20 +337,13 @@ private File getGeneratedIndexFile() { /** * Returns an input stream for the generated indexes file or {@code null} if it doesn't exist. */ - // @Nullable // @VisibleForTesting - InputStream getGeneratedIndexFileInputStream() { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public InputStream run() { - try { - return new FileInputStream(getGeneratedIndexFile()); - } catch (FileNotFoundException e) { - return null; - } - } - }); + @Nullable InputStream getGeneratedIndexFileInputStream() { + try { + return new FileInputStream(getGeneratedIndexFile()); + } catch (FileNotFoundException e) { + return null; + } } /** Returns a writer for the generated indexes file. */ diff --git a/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java b/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java index 7f6986cb6..bcf91afb8 100644 --- a/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java +++ b/api_dev/src/main/java/com/google/appengine/api/datastore/dev/LocalDatastoreService.java @@ -114,12 +114,8 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.nio.charset.StandardCharsets; -import java.security.AccessController; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -410,21 +406,14 @@ private static ScheduledThreadPoolExecutor createScheduler() { .setNameFormat("LocalDatastoreService-%d") .build()); scheduler.setRemoveOnCancelPolicy(true); - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - Runtime.getRuntime() - .addShutdownHook( - new Thread() { - @Override - public void run() { - cleanupActiveServices(); - } - }); - return null; - } - }); + Runtime.getRuntime() + .addShutdownHook( + new Thread() { + @Override + public void run() { + cleanupActiveServices(); + } + }); return scheduler; } @@ -633,14 +622,7 @@ private static int parseInt(String valStr, int defaultVal, String propName) { } public void start() { - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - startInternal(); - return null; - } - }); + startInternal(); } private synchronized void startInternal() { @@ -1402,16 +1384,8 @@ public boolean apply(EntityProto entity) { // store the query and return the results LiveQuery liveQuery = new LiveQuery(queryEntities, versions, query, entityComparator, clock); - // CompositeIndexManager does some filesystem reads/writes, so needs to - // be privileged. - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - LocalCompositeIndexManager.getInstance().processQuery(validatedQuery.getV3Query()); - return null; - } - }); + // CompositeIndexManager does some filesystem reads/writes + LocalCompositeIndexManager.getInstance().processQuery(validatedQuery.getV3Query()); // Using next function to prefetch results and return them from runQuery QueryResult result = @@ -3224,32 +3198,25 @@ Map getSpecialPropertyMap() { private void persist() { globalLock.writeLock().lock(); try { - AccessController.doPrivileged( - new PrivilegedExceptionAction() { - @Override - public Object run() throws IOException { - if (noStorage || !dirty) { - return null; - } + if (noStorage || !dirty) { + return; + } - long start = clock.getCurrentTime(); - try (ObjectOutputStream objectOut = - new ObjectOutputStream( - new BufferedOutputStream(new FileOutputStream(backingStore)))) { - objectOut.writeLong(-CURRENT_STORAGE_VERSION); - objectOut.writeLong(entityIdSequential.get()); - objectOut.writeLong(entityIdScattered.get()); - objectOut.writeObject(profiles); - } + long start = clock.getCurrentTime(); + try (ObjectOutputStream objectOut = + new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(backingStore)))) { + objectOut.writeLong(-CURRENT_STORAGE_VERSION); + objectOut.writeLong(entityIdSequential.get()); + objectOut.writeLong(entityIdScattered.get()); + objectOut.writeObject(profiles); + } - dirty = false; - long end = clock.getCurrentTime(); + dirty = false; + long end = clock.getCurrentTime(); - logger.log(Level.INFO, "Time to persist datastore: " + (end - start) + " ms"); - return null; - } - }); - } catch (PrivilegedActionException e) { + logger.log(Level.INFO, "Time to persist datastore: " + (end - start) + " ms"); + + } catch (Exception e) { Throwable t = e.getCause(); if (t instanceof IOException) { logger.log(Level.SEVERE, "Unable to save the datastore", e); diff --git a/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalBlobImageServlet.java b/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalBlobImageServlet.java index 593be79b8..6b8ab5e72 100644 --- a/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalBlobImageServlet.java +++ b/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalBlobImageServlet.java @@ -28,8 +28,6 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -248,82 +246,74 @@ private ParsedUrl() { /** * Transforms the given image specified in the {@code ParseUrl} argument. * - * Applies all the requested resize and crop operations to a valid image. + *

Applies all the requested resize and crop operations to a valid image. * * @param request a valid {@code ParseUrl} instance - * * @return the transformed image in an Image class - * @throws ApiProxy.ApplicationException If the image cannot be opened, - * encoded, or if the transform is malformed + * @throws ApiProxy.ApplicationException If the image cannot be opened, encoded, or if the + * transform is malformed */ protected Image transformImage(final ParsedUrl request) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Image run() { - // Obtain the image bytes as a BufferedImage - Status unusedStatus = new Status(); - ImageData imageData = - ImageData.newBuilder() - .setBlobKey(request.getBlobKey()) - .setContent(ByteString.EMPTY) - .build(); + // Obtain the image bytes as a BufferedImage + Status unusedStatus = new Status(); + ImageData imageData = + ImageData.newBuilder() + .setBlobKey(request.getBlobKey()) + .setContent(ByteString.EMPTY) + .build(); - String originalMimeType = imagesService.getMimeType(imageData); - BufferedImage img = imagesService.openImage(imageData, unusedStatus); + String originalMimeType = imagesService.getMimeType(imageData); + BufferedImage img = imagesService.openImage(imageData, unusedStatus); - // Apply the transform - if (request.hasOptions()) { - // Crop - if (request.getCrop()) { - Transform.Builder cropXform = null; - float width = img.getWidth(); - float height = img.getHeight(); - if (width > height) { - cropXform = Transform.newBuilder(); - float delta = (width - height) / (width * 2.0f); - cropXform.setCropLeftX(delta); - cropXform.setCropRightX(1.0f - delta); - } else if (width < height) { - cropXform = Transform.newBuilder(); - float delta = (height - width) / (height * 2.0f); - float topDelta = Math.max(0.0f, delta - 0.25f); - float bottomDelta = 1.0f - (2.0f * delta) + topDelta; - cropXform.setCropTopY(topDelta); - cropXform.setCropBottomY(bottomDelta); - } - if (cropXform != null) { - img = imagesService.processTransform(img, cropXform.build(), unusedStatus); - } - } + // Apply the transform + if (request.hasOptions()) { + // Crop + if (request.getCrop()) { + Transform.Builder cropXform = null; + float width = img.getWidth(); + float height = img.getHeight(); + if (width > height) { + cropXform = Transform.newBuilder(); + float delta = (width - height) / (width * 2.0f); + cropXform.setCropLeftX(delta); + cropXform.setCropRightX(1.0f - delta); + } else if (width < height) { + cropXform = Transform.newBuilder(); + float delta = (height - width) / (height * 2.0f); + float topDelta = Math.max(0.0f, delta - 0.25f); + float bottomDelta = 1.0f - (2.0f * delta) + topDelta; + cropXform.setCropTopY(topDelta); + cropXform.setCropBottomY(bottomDelta); + } + if (cropXform != null) { + img = imagesService.processTransform(img, cropXform.build(), unusedStatus); + } + } - // Resize - Transform resizeXform = - Transform.newBuilder() - .setWidth(request.getResize()) - .setHeight(request.getResize()) - .build(); - img = imagesService.processTransform(img, resizeXform, unusedStatus); - } else if (img.getWidth() > DEFAULT_SERVING_SIZE - || img.getHeight() > DEFAULT_SERVING_SIZE) { - // Resize down to default serving size. - Transform resizeXform = - Transform.newBuilder() - .setWidth(DEFAULT_SERVING_SIZE) - .setHeight(DEFAULT_SERVING_SIZE) - .build(); - img = imagesService.processTransform(img, resizeXform, unusedStatus); - } + // Resize + Transform resizeXform = + Transform.newBuilder() + .setWidth(request.getResize()) + .setHeight(request.getResize()) + .build(); + img = imagesService.processTransform(img, resizeXform, unusedStatus); + } else if (img.getWidth() > DEFAULT_SERVING_SIZE || img.getHeight() > DEFAULT_SERVING_SIZE) { + // Resize down to default serving size. + Transform resizeXform = + Transform.newBuilder() + .setWidth(DEFAULT_SERVING_SIZE) + .setHeight(DEFAULT_SERVING_SIZE) + .build(); + img = imagesService.processTransform(img, resizeXform, unusedStatus); + } - MIME_TYPE outputMimeType = MIME_TYPE.JPEG; - String outputMimeTypeString = "image/jpeg"; - if (transcodeToPng.contains(originalMimeType)) { - outputMimeType = MIME_TYPE.PNG; - outputMimeTypeString = "image/png"; - } - return new Image( - imagesService.saveImage(img, outputMimeType, unusedStatus), outputMimeTypeString); - } - }); + MIME_TYPE outputMimeType = MIME_TYPE.JPEG; + String outputMimeTypeString = "image/jpeg"; + if (transcodeToPng.contains(originalMimeType)) { + outputMimeType = MIME_TYPE.PNG; + outputMimeTypeString = "image/png"; + } + return new Image( + imagesService.saveImage(img, outputMimeType, unusedStatus), outputMimeTypeString); } } diff --git a/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalImagesService.java b/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalImagesService.java index 30c5603b0..6d45317dc 100644 --- a/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalImagesService.java +++ b/api_dev/src/main/java/com/google/appengine/api/images/dev/LocalImagesService.java @@ -61,8 +61,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -173,94 +171,88 @@ public void stop() {} */ public ImagesTransformResponse transform( final Status status, final ImagesTransformRequest request) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ImagesTransformResponse run() { - BufferedImage img = openImage(request.getImage(), status); - if (request.getTransformCount() > ImagesService.MAX_TRANSFORMS_PER_REQUEST) { - // TODO: Do we need to set both fields *and* throw an - // exception? - status.setSuccessful(false); - status.setErrorCode(ErrorCode.BAD_TRANSFORM_DATA.getNumber()); - throw new ApiProxy.ApplicationException( - ErrorCode.BAD_TRANSFORM_DATA.getNumber(), - String.format( - "%d transforms were supplied; the maximum allowed is %d.", - request.getTransformCount(), ImagesService.MAX_TRANSFORMS_PER_REQUEST)); - } - int orientation = 1; - if (request.getInput().getCorrectExifOrientation() - == ORIENTATION_CORRECTION_TYPE.CORRECT_ORIENTATION) { - Exif exif = getExifMetadata(request.getImage()); - if (exif != null) { - Entry entry = exif.getTagValue(Exif.ORIENTATION, true); - if (entry != null) { - orientation = ((Integer) entry.getValue(0)).intValue(); - if (img.getHeight() > img.getWidth()) { - orientation = 1; - } - } - } - } - for (Transform transform : request.getTransformList()) { - // In production, orientation correction is done during the first - // transform. If the first transform is a crop or flip it is done - // after, otherwise it is done before. To be precise, the order - // of transformation within a single entry is: Crop, Flip, - // Rotate, Resize, (Crop-to-fit), Effects (e.g., autolevels). - // Orientation fix is done within the chain modifying flipping - // and rotation steps. - if (orientation != 1 - && !(transform.hasCropRightX() - || transform.hasCropTopY() - || transform.hasCropBottomY() - || transform.hasCropLeftX()) - && !transform.hasHorizontalFlip() - && !transform.hasVerticalFlip()) { - img = correctOrientation(img, status, orientation); - orientation = 1; - } - if (transform.getAllowStretch() && transform.getCropToFit()) { - // Process allow stretch first and then process the crop. - // This is similar to how it works in production and allows us - // to keep the dev processing pipeline straightforward for this - // combination of transforms. - Transform.Builder stretch = Transform.newBuilder(); - stretch - .setWidth(transform.getWidth()) - .setHeight(transform.getHeight()) - .setAllowStretch(true); - img = processTransform(img, stretch.build(), status); - // Create and process the new crop portion of the transform. - Transform.Builder crop = Transform.newBuilder(); - crop.setWidth(transform.getWidth()) - .setHeight(transform.getHeight()) - .setCropToFit(transform.getCropToFit()) - .setCropOffsetX(transform.getCropOffsetX()) - .setCropOffsetY(transform.getCropOffsetY()) - .setAllowStretch(false); - img = processTransform(img, crop.build(), status); - } else { - img = processTransform(img, transform, status); - } - if (orientation != 1) { - img = correctOrientation(img, status, orientation); - orientation = 1; - } - } - status.setSuccessful(true); - ImageData imageData = - ImageData.newBuilder() - .setContent( - ByteString.copyFrom( - saveImage(img, request.getOutput().getMimeType(), status))) - .setWidth(img.getWidth()) - .setHeight(img.getHeight()) - .build(); - return ImagesTransformResponse.newBuilder().setImage(imageData).build(); + BufferedImage img = openImage(request.getImage(), status); + if (request.getTransformCount() > ImagesService.MAX_TRANSFORMS_PER_REQUEST) { + // TODO: Do we need to set both fields *and* throw an + // exception? + status.setSuccessful(false); + status.setErrorCode(ErrorCode.BAD_TRANSFORM_DATA.getNumber()); + throw new ApiProxy.ApplicationException( + ErrorCode.BAD_TRANSFORM_DATA.getNumber(), + String.format( + "%d transforms were supplied; the maximum allowed is %d.", + request.getTransformCount(), ImagesService.MAX_TRANSFORMS_PER_REQUEST)); + } + int orientation = 1; + if (request.getInput().getCorrectExifOrientation() + == ORIENTATION_CORRECTION_TYPE.CORRECT_ORIENTATION) { + Exif exif = getExifMetadata(request.getImage()); + if (exif != null) { + Entry entry = exif.getTagValue(Exif.ORIENTATION, true); + if (entry != null) { + orientation = ((Integer) entry.getValue(0)).intValue(); + if (img.getHeight() > img.getWidth()) { + orientation = 1; } - }); + } + } + } + for (Transform transform : request.getTransformList()) { + // In production, orientation correction is done during the first + // transform. If the first transform is a crop or flip it is done + // after, otherwise it is done before. To be precise, the order + // of transformation within a single entry is: Crop, Flip, + // Rotate, Resize, (Crop-to-fit), Effects (e.g., autolevels). + // Orientation fix is done within the chain modifying flipping + // and rotation steps. + if (orientation != 1 + && !(transform.hasCropRightX() + || transform.hasCropTopY() + || transform.hasCropBottomY() + || transform.hasCropLeftX()) + && !transform.hasHorizontalFlip() + && !transform.hasVerticalFlip()) { + img = correctOrientation(img, status, orientation); + orientation = 1; + } + if (transform.getAllowStretch() && transform.getCropToFit()) { + // Process allow stretch first and then process the crop. + // This is similar to how it works in production and allows us + // to keep the dev processing pipeline straightforward for this + // combination of transforms. + Transform.Builder stretch = Transform.newBuilder(); + stretch + .setWidth(transform.getWidth()) + .setHeight(transform.getHeight()) + .setAllowStretch(true); + img = processTransform(img, stretch.build(), status); + // Create and process the new crop portion of the transform. + Transform.Builder crop = Transform.newBuilder(); + crop.setWidth(transform.getWidth()) + .setHeight(transform.getHeight()) + .setCropToFit(transform.getCropToFit()) + .setCropOffsetX(transform.getCropOffsetX()) + .setCropOffsetY(transform.getCropOffsetY()) + .setAllowStretch(false); + img = processTransform(img, crop.build(), status); + } else { + img = processTransform(img, transform, status); + } + if (orientation != 1) { + img = correctOrientation(img, status, orientation); + orientation = 1; + } + } + status.setSuccessful(true); + ImageData imageData = + ImageData.newBuilder() + .setContent( + ByteString.copyFrom( + saveImage(img, request.getOutput().getMimeType(), status))) + .setWidth(img.getWidth()) + .setHeight(img.getHeight()) + .build(); + return ImagesTransformResponse.newBuilder().setImage(imageData).build(); } /** @@ -270,50 +262,44 @@ public ImagesTransformResponse run() { */ public ImagesCompositeResponse composite( final Status status, final ImagesCompositeRequest request) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ImagesCompositeResponse run() { - List images = new ArrayList(request.getImageCount()); - for (int i = 0; i < request.getImageCount(); i++) { - images.add(openImage(request.getImage(i), status)); - } - if (request.getOptionsCount() > ImagesService.MAX_COMPOSITES_PER_REQUEST) { - status.setSuccessful(false); - status.setErrorCode(ErrorCode.BAD_TRANSFORM_DATA.getNumber()); - throw new ApiProxy.ApplicationException(ErrorCode.BAD_TRANSFORM_DATA.getNumber(), - String.format("%d composites were supplied; the maximum allowed is %d.", - request.getOptionsCount(), ImagesService.MAX_COMPOSITES_PER_REQUEST)); - } - int width = request.getCanvas().getWidth(); - int height = request.getCanvas().getHeight(); - int color = request.getCanvas().getColor(); - BufferedImage canvas = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - canvas.setRGB(j, i, color); - } - } - for (int i = 0; i < request.getOptionsCount(); i++) { - CompositeImageOptions options = request.getOptions(i); - if (options.getSourceIndex() < 0 - || options.getSourceIndex() >= request.getImageCount()) { - throw new ApiProxy.ApplicationException(ErrorCode.BAD_TRANSFORM_DATA.getNumber(), - String.format("Invalid source image index %d", options.getSourceIndex())); - } - processComposite(canvas, options, images.get(options.getSourceIndex()), status); - } - status.setSuccessful(true); - return ImagesCompositeResponse - .newBuilder() - .setImage( - ImageData.newBuilder().setContent(ByteString.copyFrom(saveImage(canvas, request - .getCanvas() - .getOutput() - .getMimeType(), status)))) - .build(); - } - }); + List images = new ArrayList(request.getImageCount()); + for (int i = 0; i < request.getImageCount(); i++) { + images.add(openImage(request.getImage(i), status)); + } + if (request.getOptionsCount() > ImagesService.MAX_COMPOSITES_PER_REQUEST) { + status.setSuccessful(false); + status.setErrorCode(ErrorCode.BAD_TRANSFORM_DATA.getNumber()); + throw new ApiProxy.ApplicationException(ErrorCode.BAD_TRANSFORM_DATA.getNumber(), + String.format("%d composites were supplied; the maximum allowed is %d.", + request.getOptionsCount(), ImagesService.MAX_COMPOSITES_PER_REQUEST)); + } + int width = request.getCanvas().getWidth(); + int height = request.getCanvas().getHeight(); + int color = request.getCanvas().getColor(); + BufferedImage canvas = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + canvas.setRGB(j, i, color); + } + } + for (int i = 0; i < request.getOptionsCount(); i++) { + CompositeImageOptions options = request.getOptions(i); + if (options.getSourceIndex() < 0 + || options.getSourceIndex() >= request.getImageCount()) { + throw new ApiProxy.ApplicationException(ErrorCode.BAD_TRANSFORM_DATA.getNumber(), + String.format("Invalid source image index %d", options.getSourceIndex())); + } + processComposite(canvas, options, images.get(options.getSourceIndex()), status); + } + status.setSuccessful(true); + return ImagesCompositeResponse + .newBuilder() + .setImage( + ImageData.newBuilder().setContent(ByteString.copyFrom(saveImage(canvas, request + .getCanvas() + .getOutput() + .getMimeType(), status)))) + .build(); } /** @@ -463,36 +449,30 @@ public byte[] saveImage(BufferedImage image, MIME_TYPE mimeType, Status status) */ public ImagesHistogramResponse histogram( final Status status, final ImagesHistogramRequest request) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ImagesHistogramResponse run() { - BufferedImage img = openImage(request.getImage(), status); - int[] red = new int[256]; - int[] green = new int[256]; - int[] blue = new int[256]; - int pixel; - for (int i = 0; i < img.getHeight(); i++) { - for (int j = 0; j < img.getWidth(); j++) { - pixel = img.getRGB(j, i); - // Premultiply by alpha to match thumbnailer. - red[(((pixel >> 16) & 0xff) * ((pixel >> 24) & 0xff)) / 255]++; - green[(((pixel >> 8) & 0xff) * ((pixel >> 24) & 0xff)) / 255]++; - blue[((pixel & 0xff) * ((pixel >> 24) & 0xff)) / 255]++; - } - } - ImagesHistogram.Builder imageHistogram = ImagesHistogram.newBuilder(); - for (int i = 0; i < 256; i++) { - imageHistogram.addRed(red[i]); - imageHistogram.addGreen(green[i]); - imageHistogram.addBlue(blue[i]); - } - return ImagesHistogramResponse - .newBuilder() - .setHistogram(imageHistogram) - .build(); - } - }); + BufferedImage img = openImage(request.getImage(), status); + int[] red = new int[256]; + int[] green = new int[256]; + int[] blue = new int[256]; + int pixel; + for (int i = 0; i < img.getHeight(); i++) { + for (int j = 0; j < img.getWidth(); j++) { + pixel = img.getRGB(j, i); + // Premultiply by alpha to match thumbnailer. + red[(((pixel >> 16) & 0xff) * ((pixel >> 24) & 0xff)) / 255]++; + green[(((pixel >> 8) & 0xff) * ((pixel >> 24) & 0xff)) / 255]++; + blue[((pixel & 0xff) * ((pixel >> 24) & 0xff)) / 255]++; + } + } + ImagesHistogram.Builder imageHistogram = ImagesHistogram.newBuilder(); + for (int i = 0; i < 256; i++) { + imageHistogram.addRed(red[i]); + imageHistogram.addGreen(green[i]); + imageHistogram.addBlue(blue[i]); + } + return ImagesHistogramResponse + .newBuilder() + .setHistogram(imageHistogram) + .build(); } /** @@ -505,46 +485,34 @@ public ImagesHistogramResponse run() { */ public ImagesGetUrlBaseResponse getUrlBase( final Status status, final ImagesGetUrlBaseRequest request) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ImagesGetUrlBaseResponse run() { - if (request.getCreateSecureUrl()) { - log.info( - "Secure URLs will not be created using the development " + "application server."); - } - // Detect the image mimetype to see if is a valid image. - ImageData imageData = - ImageData.newBuilder() - .setBlobKey(request.getBlobKey()) - .setContent(ByteString.EMPTY) - .build(); - // getMimeType is validating the blob is an image. - getMimeType(imageData); - // Note I am commenting out the following line - // because experimentats indicates that doing so resolves - // b/7031367 Tests time out with OOMs since 1.7.1 - // TODO Figure out why the following line causes this - // test to take over one minute to finish: - // jt/c/g/dotorg/onetoday/server/offer/selection:FriendsMatchingScorerTest - // addServingUrlEntry(request.getBlobKey()); - return ImagesGetUrlBaseResponse.newBuilder() - .setUrl(hostPrefix + "/_ah/img/" + request.getBlobKey()) - .build(); - } - }); + if (request.getCreateSecureUrl()) { + log.info( + "Secure URLs will not be created using the development " + "application server."); + } + // Detect the image mimetype to see if is a valid image. + ImageData imageData = + ImageData.newBuilder() + .setBlobKey(request.getBlobKey()) + .setContent(ByteString.EMPTY) + .build(); + // getMimeType is validating the blob is an image. + getMimeType(imageData); + // Note I am commenting out the following line + // because experimentats indicates that doing so resolves + // b/7031367 Tests time out with OOMs since 1.7.1 + // TODO Figure out why the following line causes this + // test to take over one minute to finish: + // jt/c/g/dotorg/onetoday/server/offer/selection:FriendsMatchingScorerTest + // addServingUrlEntry(request.getBlobKey()); + return ImagesGetUrlBaseResponse.newBuilder() + .setUrl(hostPrefix + "/_ah/img/" + request.getBlobKey()) + .build(); } public ImagesDeleteUrlBaseResponse deleteUrlBase( final Status status, final ImagesDeleteUrlBaseRequest request) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ImagesDeleteUrlBaseResponse run() { - deleteServingUrlEntry(request.getBlobKey()); - return ImagesDeleteUrlBaseResponse.newBuilder().build(); - } - }); + deleteServingUrlEntry(request.getBlobKey()); + return ImagesDeleteUrlBaseResponse.newBuilder().build(); } @Override diff --git a/api_dev/src/main/java/com/google/appengine/api/images/dev/ee10/LocalBlobImageServlet.java b/api_dev/src/main/java/com/google/appengine/api/images/dev/ee10/LocalBlobImageServlet.java index f93433f42..ca2e18e27 100644 --- a/api_dev/src/main/java/com/google/appengine/api/images/dev/ee10/LocalBlobImageServlet.java +++ b/api_dev/src/main/java/com/google/appengine/api/images/dev/ee10/LocalBlobImageServlet.java @@ -33,8 +33,6 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -249,82 +247,74 @@ private ParsedUrl() { /** * Transforms the given image specified in the {@code ParseUrl} argument. * - * Applies all the requested resize and crop operations to a valid image. + *

Applies all the requested resize and crop operations to a valid image. * * @param request a valid {@code ParseUrl} instance - * * @return the transformed image in an Image class - * @throws ApiProxy.ApplicationException If the image cannot be opened, - * encoded, or if the transform is malformed + * @throws ApiProxy.ApplicationException If the image cannot be opened, encoded, or if the + * transform is malformed */ protected Image transformImage(final ParsedUrl request) { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Image run() { - // Obtain the image bytes as a BufferedImage - Status unusedStatus = new Status(); - ImageData imageData = - ImageData.newBuilder() - .setBlobKey(request.getBlobKey()) - .setContent(ByteString.EMPTY) - .build(); + // Obtain the image bytes as a BufferedImage + Status unusedStatus = new Status(); + ImageData imageData = + ImageData.newBuilder() + .setBlobKey(request.getBlobKey()) + .setContent(ByteString.EMPTY) + .build(); - String originalMimeType = imagesService.getMimeType(imageData); - BufferedImage img = imagesService.openImage(imageData, unusedStatus); + String originalMimeType = imagesService.getMimeType(imageData); + BufferedImage img = imagesService.openImage(imageData, unusedStatus); - // Apply the transform - if (request.hasOptions()) { - // Crop - if (request.getCrop()) { - Transform.Builder cropXform = null; - float width = img.getWidth(); - float height = img.getHeight(); - if (width > height) { - cropXform = Transform.newBuilder(); - float delta = (width - height) / (width * 2.0f); - cropXform.setCropLeftX(delta); - cropXform.setCropRightX(1.0f - delta); - } else if (width < height) { - cropXform = Transform.newBuilder(); - float delta = (height - width) / (height * 2.0f); - float topDelta = Math.max(0.0f, delta - 0.25f); - float bottomDelta = 1.0f - (2.0f * delta) + topDelta; - cropXform.setCropTopY(topDelta); - cropXform.setCropBottomY(bottomDelta); - } - if (cropXform != null) { - img = imagesService.processTransform(img, cropXform.build(), unusedStatus); - } - } + // Apply the transform + if (request.hasOptions()) { + // Crop + if (request.getCrop()) { + Transform.Builder cropXform = null; + float width = img.getWidth(); + float height = img.getHeight(); + if (width > height) { + cropXform = Transform.newBuilder(); + float delta = (width - height) / (width * 2.0f); + cropXform.setCropLeftX(delta); + cropXform.setCropRightX(1.0f - delta); + } else if (width < height) { + cropXform = Transform.newBuilder(); + float delta = (height - width) / (height * 2.0f); + float topDelta = Math.max(0.0f, delta - 0.25f); + float bottomDelta = 1.0f - (2.0f * delta) + topDelta; + cropXform.setCropTopY(topDelta); + cropXform.setCropBottomY(bottomDelta); + } + if (cropXform != null) { + img = imagesService.processTransform(img, cropXform.build(), unusedStatus); + } + } - // Resize - Transform resizeXform = - Transform.newBuilder() - .setWidth(request.getResize()) - .setHeight(request.getResize()) - .build(); - img = imagesService.processTransform(img, resizeXform, unusedStatus); - } else if (img.getWidth() > DEFAULT_SERVING_SIZE - || img.getHeight() > DEFAULT_SERVING_SIZE) { - // Resize down to default serving size. - Transform resizeXform = - Transform.newBuilder() - .setWidth(DEFAULT_SERVING_SIZE) - .setHeight(DEFAULT_SERVING_SIZE) - .build(); - img = imagesService.processTransform(img, resizeXform, unusedStatus); - } + // Resize + Transform resizeXform = + Transform.newBuilder() + .setWidth(request.getResize()) + .setHeight(request.getResize()) + .build(); + img = imagesService.processTransform(img, resizeXform, unusedStatus); + } else if (img.getWidth() > DEFAULT_SERVING_SIZE || img.getHeight() > DEFAULT_SERVING_SIZE) { + // Resize down to default serving size. + Transform resizeXform = + Transform.newBuilder() + .setWidth(DEFAULT_SERVING_SIZE) + .setHeight(DEFAULT_SERVING_SIZE) + .build(); + img = imagesService.processTransform(img, resizeXform, unusedStatus); + } - MIME_TYPE outputMimeType = MIME_TYPE.JPEG; - String outputMimeTypeString = "image/jpeg"; - if (transcodeToPng.contains(originalMimeType)) { - outputMimeType = MIME_TYPE.PNG; - outputMimeTypeString = "image/png"; - } - return new Image( - imagesService.saveImage(img, outputMimeType, unusedStatus), outputMimeTypeString); - } - }); + MIME_TYPE outputMimeType = MIME_TYPE.JPEG; + String outputMimeTypeString = "image/jpeg"; + if (transcodeToPng.contains(originalMimeType)) { + outputMimeType = MIME_TYPE.PNG; + outputMimeTypeString = "image/png"; + } + return new Image( + imagesService.saveImage(img, outputMimeType, unusedStatus), outputMimeTypeString); } } diff --git a/api_dev/src/main/java/com/google/appengine/api/search/dev/LocalSearchService.java b/api_dev/src/main/java/com/google/appengine/api/search/dev/LocalSearchService.java index 099d441a3..7a62b1e2a 100644 --- a/api_dev/src/main/java/com/google/appengine/api/search/dev/LocalSearchService.java +++ b/api_dev/src/main/java/com/google/appengine/api/search/dev/LocalSearchService.java @@ -48,9 +48,6 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.nio.charset.StandardCharsets; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -843,17 +840,11 @@ private void clearIndexes(final File indexDirectory) { } else { closeIndexWriters(); try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Object run() throws IOException { - if (indexDirectory.exists()) { - recursiveDelete(indexDirectory); - } - indexDirectory.mkdirs(); - return null; - } - }); - } catch (PrivilegedActionException e) { + if (indexDirectory.exists()) { + recursiveDelete(indexDirectory); + } + indexDirectory.mkdirs(); + } catch (IOException e) { throw new RuntimeException(e); } dirMap = new LuceneDirectoryMap.FileBased(indexDirectory); diff --git a/api_dev/src/main/java/com/google/appengine/api/taskqueue/dev/LocalTaskQueue.java b/api_dev/src/main/java/com/google/appengine/api/taskqueue/dev/LocalTaskQueue.java index 0c2ea1020..eff4593ba 100644 --- a/api_dev/src/main/java/com/google/appengine/api/taskqueue/dev/LocalTaskQueue.java +++ b/api_dev/src/main/java/com/google/appengine/api/taskqueue/dev/LocalTaskQueue.java @@ -57,8 +57,6 @@ import java.net.Inet6Address; import java.net.InetAddress; import java.nio.file.Paths; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Collections; import java.util.HashMap; import java.util.IdentityHashMap; @@ -272,14 +270,7 @@ void setQueueXml(QueueXml queueXml) { @Override public void start() { - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - start_(); - return null; - } - }); + start_(); } private void start_() { @@ -347,14 +338,7 @@ static String getBaseUrl(LocalServerEnvironment localServerEnvironment) { public void stop() { // Avoid removing the shutdownHook while a JVM shutdown is in progress. if (shutdownHook != null) { - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Void run() { - Runtime.getRuntime().removeShutdownHook(shutdownHook); - return null; - } - }); + Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; } stop_(); diff --git a/api_dev/src/main/java/com/google/appengine/api/urlfetch/dev/LocalURLFetchService.java b/api_dev/src/main/java/com/google/appengine/api/urlfetch/dev/LocalURLFetchService.java index 6ee62cdee..997e11700 100644 --- a/api_dev/src/main/java/com/google/appengine/api/urlfetch/dev/LocalURLFetchService.java +++ b/api_dev/src/main/java/com/google/appengine/api/urlfetch/dev/LocalURLFetchService.java @@ -35,13 +35,10 @@ import java.net.ProxySelector; import java.net.SocketTimeoutException; import java.net.URL; -import java.security.AccessController; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Arrays; @@ -465,43 +462,26 @@ private HttpResponse doPrivilegedExecute( final HttpRequestBase method, final URLFetchResponse.Builder response) throws IOException { - try { - return AccessController.doPrivileged( - new PrivilegedExceptionAction() { - @Override - public HttpResponse run() throws IOException { - HttpContext context = new BasicHttpContext(); - // Does some thread ops we need to do in a privileged block. - HttpResponse httpResponse; - // TODO: Default behavior reverted to not validating cert for - // 1.4.2 CP due to wildcard cert validation problems. Revert for - // 1.4.4 after we're confident that the new HttpClient has fixed the - // behavior. - if (request.hasMustValidateServerCertificate() - && request.getMustValidateServerCertificate()) { - httpResponse = getValidatingClient().execute(method, context); - } else { - httpResponse = getNonValidatingClient().execute(method, context); - } - response.setStatusCode(httpResponse.getStatusLine().getStatusCode()); - HttpHost lastHost = - (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); - HttpUriRequest lastReq = - (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST); - String lastUrl = lastHost.toURI() + lastReq.getURI(); - if (!lastUrl.equals(method.getURI().toString())) { - response.setFinalUrl(lastUrl); - } - return httpResponse; - } - }); - } catch (PrivilegedActionException e) { - Throwable t = e.getCause(); - if (t instanceof IOException) { - throw (IOException) t; - } - throw new RuntimeException(e); + HttpContext context = new BasicHttpContext(); + // Does some thread ops we need to do in a privileged block. + HttpResponse httpResponse; + // TODO: Default behavior reverted to not validating cert for + // 1.4.2 CP due to wildcard cert validation problems. Revert for + // 1.4.4 after we're confident that the new HttpClient has fixed the + // behavior. + if (request.hasMustValidateServerCertificate() && request.getMustValidateServerCertificate()) { + httpResponse = getValidatingClient().execute(method, context); + } else { + httpResponse = getNonValidatingClient().execute(method, context); + } + response.setStatusCode(httpResponse.getStatusLine().getStatusCode()); + HttpHost lastHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); + HttpUriRequest lastReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST); + String lastUrl = lastHost.toURI() + lastReq.getURI(); + if (!lastUrl.equals(method.getURI().toString())) { + response.setFinalUrl(lastUrl); } + return httpResponse; } boolean isAllowedPort(int port) { diff --git a/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java b/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java index 9304d3b12..09e7a9035 100644 --- a/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java +++ b/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java @@ -26,8 +26,6 @@ import com.google.apphosting.api.ApiProxy.UnknownException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -42,8 +40,6 @@ import java.util.concurrent.Future; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; import org.checkerframework.checker.nullness.qual.Nullable; @@ -216,15 +212,9 @@ public Future makeAsyncCall( boolean offline = environment.getAttributes().get(IS_OFFLINE_REQUEST_KEY) != null; boolean success = false; try { - // Despite the name, privilegedCallable() just arranges for this - // callable to be run with the current privileges. - Callable callable = Executors.privilegedCallable(asyncApiCall); - - // Now we need to escalate privileges so we have permission to - // spin up new threads, if necessary. The callable itself will - // run with the previous privileges. - Future resultFuture = AccessController.doPrivileged( - new PrivilegedApiAction(callable, asyncApiCall)); + Callable callable = asyncApiCall; + Future resultFuture = apiExecutor.submit(callable); + success = true; if (context.getLocalServerEnvironment().enforceApiDeadlines()) { long deadlineMillis = (long) (1000.0 * resolveDeadline(packageName, apiConfig, offline)); @@ -274,67 +264,6 @@ private double resolveDeadline( return Math.min(deadline, maxDeadline); } - private class PrivilegedApiAction implements PrivilegedAction> { - - private final Callable callable; - private final AsyncApiCall asyncApiCall; - - PrivilegedApiAction(Callable callable, AsyncApiCall asyncApiCall) { - this.callable = callable; - this.asyncApiCall = asyncApiCall; - } - - @Override - public Future run() { - // TODO: Return something that implements - // ApiProxy.ApiResultFuture so we can attach real wallclock - // time information here (although CPU time is irrelevant). - final Future result = apiExecutor.submit(callable); - return new Future() { - @Override - public boolean cancel(final boolean mayInterruptIfRunning) { - // Cancel may interrupt another thread so we need to escalate privileges to avoid - // sandbox restrictions. - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Boolean run() { - // If we cancel the task before it runs it's up to us to - // release the semaphore. If we cancel the task after it - // runs we know the task released the semaphore. However, - // we can't reliably know the state of the task and it's - // bad news if the semaphore gets released twice. This - // method ensures that the semaphore only gets released once. - asyncApiCall.tryReleaseSemaphore(); - return result.cancel(mayInterruptIfRunning); - } - }); - } - - @Override - public boolean isCancelled() { - return result.isCancelled(); - } - - @Override - public boolean isDone() { - return result.isDone(); - } - - @Override - public byte[] get() throws InterruptedException, ExecutionException { - return result.get(); - } - - @Override - public byte[] get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return result.get(timeout, unit); - } - }; - } - } - @Override public void setProperty(String serviceProperty, String value) { if (serviceProperty == null) { @@ -568,13 +497,7 @@ public final synchronized LocalRpcService getService(final String pkg) { return cachedService; } - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public LocalRpcService run() { - return startServices(pkg); - } - }); + return startServices(pkg); } @Override diff --git a/api_dev/src/main/java/com/google/appengine/tools/development/BackgroundThreadFactory.java b/api_dev/src/main/java/com/google/appengine/tools/development/BackgroundThreadFactory.java index 6ae5be95f..01315d635 100644 --- a/api_dev/src/main/java/com/google/appengine/tools/development/BackgroundThreadFactory.java +++ b/api_dev/src/main/java/com/google/appengine/tools/development/BackgroundThreadFactory.java @@ -17,8 +17,6 @@ package com.google.appengine.tools.development; import com.google.apphosting.api.ApiProxy; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.concurrent.ThreadFactory; import java.util.logging.Level; import java.util.logging.Logger; @@ -55,28 +53,22 @@ public Thread newThread(final Runnable runnable) { LocalEnvironment.getCurrentInstance(), LocalEnvironment.getCurrentPort()); sleepUninterruptably(API_CALL_LATENCY_MS); - return AccessController.doPrivileged( - new PrivilegedAction() { + // TODO: Only allow this to be used from a backend. + Thread thread = + new Thread(runnable) { @Override - public Thread run() { - // TODO: Only allow this to be used from a backend. - Thread thread = - new Thread(runnable) { - @Override - public void run() { - sleepUninterruptably(THREAD_STARTUP_LATENCY_MS); - ApiProxy.setEnvironmentForCurrentThread(environment); - try { - runnable.run(); - } finally { - environment.callRequestEndListeners(); - } - } - }; - System.setProperty("devappserver-thread-" + thread.getName(), "true"); - return thread; + public void run() { + sleepUninterruptably(THREAD_STARTUP_LATENCY_MS); + ApiProxy.setEnvironmentForCurrentThread(environment); + try { + runnable.run(); + } finally { + environment.callRequestEndListeners(); + } } - }); + }; + System.setProperty("devappserver-thread-" + thread.getName(), "true"); + return thread; } final String getAppId() { diff --git a/api_dev/src/main/java/com/google/appengine/tools/development/DevAppServerImpl.java b/api_dev/src/main/java/com/google/appengine/tools/development/DevAppServerImpl.java index 034297ba1..dc20912ab 100644 --- a/api_dev/src/main/java/com/google/appengine/tools/development/DevAppServerImpl.java +++ b/api_dev/src/main/java/com/google/appengine/tools/development/DevAppServerImpl.java @@ -29,10 +29,6 @@ import com.google.common.collect.ImmutableSet; import java.io.File; import java.net.BindException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; import java.util.TimeZone; @@ -222,23 +218,14 @@ public Map getServiceProperties() { /** * Starts the server. * - * @throws IllegalStateException If the server has already been started or - * shutdown. + * @throws IllegalStateException If the server has already been started or shutdown. * @throws AppEngineConfigException If no WEB-INF directory can be found or - * WEB-INF/appengine-web.xml does not exist. + * WEB-INF/appengine-web.xml does not exist. * @return a latch that will be decremented to zero when the server is shutdown. */ @Override public CountDownLatch start() throws Exception { - try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override public CountDownLatch run() throws Exception { - return doStart(); - } - }); - } catch (PrivilegedActionException e) { - throw e.getException(); - } + return doStart(); } private CountDownLatch doStart() throws Exception { @@ -374,24 +361,16 @@ public CountDownLatch restart() throws Exception { if (serverState != ServerState.RUNNING) { throw new IllegalStateException("Cannot restart a server that is not currently running."); } - try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override public CountDownLatch run() throws Exception { - modules.shutdown(); - backendContainer.shutdownAll(); - shutdownLatch.countDown(); - modules.createConnections(); - backendContainer.configureAll(apiProxyLocal); - modules.setApiProxyDelegate(apiProxyLocal); - modules.startup(); - backendContainer.startupAll(); - shutdownLatch = new CountDownLatch(1); - return shutdownLatch; - } - }); - } catch (PrivilegedActionException e) { - throw e.getException(); - } + modules.shutdown(); + backendContainer.shutdownAll(); + shutdownLatch.countDown(); + modules.createConnections(); + backendContainer.configureAll(apiProxyLocal); + modules.setApiProxyDelegate(apiProxyLocal); + modules.startup(); + backendContainer.startupAll(); + shutdownLatch = new CountDownLatch(1); + return shutdownLatch; } @Override @@ -399,46 +378,29 @@ public void shutdown() throws Exception { if (serverState != ServerState.RUNNING) { throw new IllegalStateException("Cannot shutdown a server that is not currently running."); } - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override public Void run() throws Exception { - modules.shutdown(); - backendContainer.shutdownAll(); - ApiProxy.setDelegate(null); - apiProxyLocal = null; - serverState = ServerState.SHUTDOWN; - shutdownLatch.countDown(); - return null; - } - }); - } catch (PrivilegedActionException e) { - throw e.getException(); - } + modules.shutdown(); + backendContainer.shutdownAll(); + ApiProxy.setDelegate(null); + apiProxyLocal = null; + serverState = ServerState.SHUTDOWN; + shutdownLatch.countDown(); } @Override public void gracefulShutdown() throws IllegalStateException { // TODO: Do an actual graceful shutdown rather than just delaying. - // Requires a privileged block since this may be invoked from a servlet - // that lives in the user's classloader and may result in the creation of - // a thread. - AccessController.doPrivileged( - new PrivilegedAction>() { - @Override - public Future run() { - return shutdownScheduler.schedule( - new Callable() { - @Override - public Void call() throws Exception { - shutdown(); - return null; - } - }, - 1000, - TimeUnit.MILLISECONDS); - } - }); + Future unused = + shutdownScheduler.schedule( + new Callable() { + @Override + public Void call() throws Exception { + shutdown(); + return null; + } + }, + 1000, + TimeUnit.MILLISECONDS); } @Override diff --git a/api_dev/src/main/java/com/google/appengine/tools/development/IsolatedAppClassLoader.java b/api_dev/src/main/java/com/google/appengine/tools/development/IsolatedAppClassLoader.java index dfa5c3436..9ed4723d5 100644 --- a/api_dev/src/main/java/com/google/appengine/tools/development/IsolatedAppClassLoader.java +++ b/api_dev/src/main/java/com/google/appengine/tools/development/IsolatedAppClassLoader.java @@ -26,9 +26,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.security.AccessController; import java.security.CodeSource; -import java.security.PrivilegedAction; import java.util.HashSet; import java.util.Set; import java.util.logging.Level; @@ -172,13 +170,7 @@ protected synchronized Class loadClass(String name, boolean resolve) final Class c = devAppServerClassLoader.loadClass(name); // See where it came from. - CodeSource source = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public CodeSource run() { - return c.getProtectionDomain().getCodeSource(); - } - }); + CodeSource source = c.getProtectionDomain().getCodeSource(); // Load classes from the JRE. // We can't just block non-allowlisted classes from being loaded. The JVM diff --git a/api_dev/src/main/java/com/google/appengine/tools/development/ManualInstanceHolder.java b/api_dev/src/main/java/com/google/appengine/tools/development/ManualInstanceHolder.java index c0453d200..48289b84d 100644 --- a/api_dev/src/main/java/com/google/appengine/tools/development/ManualInstanceHolder.java +++ b/api_dev/src/main/java/com/google/appengine/tools/development/ManualInstanceHolder.java @@ -19,8 +19,6 @@ import com.google.appengine.tools.development.ApplicationConfigurationManager.ModuleConfigurationHandle; import com.google.appengine.tools.development.InstanceStateHolder.InstanceState; import java.io.File; -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -157,18 +155,7 @@ void stopServing() throws Exception { startRequestLatch = new CountDownLatch(1); doConfigure(); createConnection(); - // We call ContainerService.startup inside a PrivilegedExceptionAction - // so threads created by the contained Jetty instance - // will not inherit our callers protection domains. See - // http://docs.oracle.com/javase/7/docs/technotes/guides/security/spec/security-spec.doc4.html - // section 4.3 for details. - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Object run() throws Exception { - getContainerService().startup(); - return null; - } - }); + getContainerService().startup(); stateHolder.testAndSet(InstanceState.STOPPED, InstanceState.INITIALIZING); } } diff --git a/api_dev/src/main/java/com/google/appengine/tools/development/RequestThreadFactory.java b/api_dev/src/main/java/com/google/appengine/tools/development/RequestThreadFactory.java index e59f0ced7..28b3f966c 100644 --- a/api_dev/src/main/java/com/google/appengine/tools/development/RequestThreadFactory.java +++ b/api_dev/src/main/java/com/google/appengine/tools/development/RequestThreadFactory.java @@ -17,9 +17,6 @@ package com.google.appengine.tools.development; import com.google.apphosting.api.ApiProxy; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Date; import java.util.Map; import java.util.concurrent.ThreadFactory; @@ -44,105 +41,93 @@ public class RequestThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable runnable) { - final AccessControlContext context = AccessController.getContext(); - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Thread run() { - final ApiProxy.Environment environment = ApiProxy.getCurrentEnvironment(); - Thread thread = - new Thread() { - /** - * If the thread is started, install a {@link RequestEndListener} to interrupt the - * thread at the end of the request. We don't yet enforce request deadlines in the - * DevAppServer so we don't need to handle other interrupt cases yet. - */ + final ApiProxy.Environment environment = ApiProxy.getCurrentEnvironment(); + + Thread thread = + new Thread() { + /** + * If the thread is started, install a {@link RequestEndListener} to interrupt the + * thread at the end of the request. We don't yet enforce request deadlines in the + * DevAppServer so we don't need to handle other interrupt cases yet. + */ + @Override + public synchronized void start() { + try { + Thread.sleep(THREAD_STARTUP_LATENCY_MS); + } catch (InterruptedException ex) { + // We can't propagate the exception from here so + // just log, reset the bit, and continue. + logger.log( + Level.INFO, "Interrupted while simulating thread startup latency", ex); + Thread.currentThread().interrupt(); + } + super.start(); + final Thread thread = this; // Thread.this doesn't work from an anon subclass + RequestEndListenerHelper.register( + new RequestEndListener() { @Override - public synchronized void start() { - try { - Thread.sleep(THREAD_STARTUP_LATENCY_MS); - } catch (InterruptedException ex) { - // We can't propagate the exception from here so - // just log, reset the bit, and continue. - logger.log( - Level.INFO, "Interrupted while simulating thread startup latency", ex); - Thread.currentThread().interrupt(); + public void onRequestEnd(ApiProxy.Environment environment) { + if (thread.isAlive()) { + logger.info("Interrupting request thread: " + thread); + thread.interrupt(); + logger.info("Waiting up to 100ms for thread to complete: " + thread); + try { + thread.join(100); + } catch (InterruptedException ex) { + logger.info("Interrupted while waiting."); + } + if (thread.isAlive()) { + logger.info("Interrupting request thread again: " + thread); + thread.interrupt(); + long remaining = getRemainingDeadlineMillis(environment); + logger.info( + "Waiting up to " + + remaining + + " ms for thread to complete: " + + thread); + try { + thread.join(remaining); + } catch (InterruptedException ex) { + logger.info("Interrupted while waiting."); + } + if (thread.isAlive()) { + Throwable stack = new Throwable(); + stack.setStackTrace(thread.getStackTrace()); + logger.log( + Level.SEVERE, + "Thread left running: " + + thread + + ". " + + "In production this will cause the request to fail.", + stack); + } + } } - super.start(); - final Thread thread = this; // Thread.this doesn't work from an anon subclass - RequestEndListenerHelper.register( - new RequestEndListener() { - @Override - public void onRequestEnd(ApiProxy.Environment environment) { - if (thread.isAlive()) { - logger.info("Interrupting request thread: " + thread); - thread.interrupt(); - logger.info("Waiting up to 100ms for thread to complete: " + thread); - try { - thread.join(100); - } catch (InterruptedException ex) { - logger.info("Interrupted while waiting."); - } - if (thread.isAlive()) { - logger.info("Interrupting request thread again: " + thread); - thread.interrupt(); - long remaining = getRemainingDeadlineMillis(environment); - logger.info( - "Waiting up to " - + remaining - + " ms for thread to complete: " - + thread); - try { - thread.join(remaining); - } catch (InterruptedException ex) { - logger.info("Interrupted while waiting."); - } - if (thread.isAlive()) { - Throwable stack = new Throwable(); - stack.setStackTrace(thread.getStackTrace()); - logger.log( - Level.SEVERE, - "Thread left running: " - + thread - + ". " - + "In production this will cause the request to fail.", - stack); - } - } - } - } - }); } + }); + } - @Override - public void run() { - // Copy the current environment to the new thread. - ApiProxy.setEnvironmentForCurrentThread(environment); - // Switch back to the calling context before running the user's code. - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - runnable.run(); - return null; - } - }, - context); - // Don't bother unsetting the environment. We're - // not going to reuse this thread and we want the - // environment still to be set during any - // UncaughtExceptionHandler (which happens after - // run() completes/throws). - } - }; - // This system property is used to check if the thread is - // running user code (ugly, I know). This thread is now - // running user code so we set it as well. - System.setProperty("devappserver-thread-" + thread.getName(), "true"); - return thread; + @Override + public void run() { + // Copy the current environment to the new thread. + ApiProxy.setEnvironmentForCurrentThread(environment); + // Switch back to the calling context before running the user's code. + runnable.run(); + // Don't bother unsetting the environment. We're + // not going to reuse this thread and we want the + // environment still to be set during any + // UncaughtExceptionHandler (which happens after + // run() completes/throws). } - }); + }; + // This system property is used to check if the thread is + // running user code (ugly, I know). This thread is now + // running user code so we set it as well. + System.setProperty("devappserver-thread-" + thread.getName(), "true"); + return thread; + + } private long getRemainingDeadlineMillis(ApiProxy.Environment environment) { diff --git a/api_legacy/pom.xml b/api_legacy/pom.xml index 32849eb03..689df6e4d 100644 --- a/api_legacy/pom.xml +++ b/api_legacy/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/appengine-api-1.0-sdk/pom.xml b/appengine-api-1.0-sdk/pom.xml index f86ba89c9..16c84f7e3 100644 --- a/appengine-api-1.0-sdk/pom.xml +++ b/appengine-api-1.0-sdk/pom.xml @@ -20,7 +20,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar AppEngine :: appengine-api-1.0-sdk diff --git a/appengine-api-stubs/pom.xml b/appengine-api-stubs/pom.xml index 406469655..444a2a07c 100644 --- a/appengine-api-stubs/pom.xml +++ b/appengine-api-stubs/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/appengine_init/pom.xml b/appengine_init/pom.xml index 4c1529c40..c83f602cf 100644 --- a/appengine_init/pom.xml +++ b/appengine_init/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/appengine_jsr107/pom.xml b/appengine_jsr107/pom.xml index 23bc8105a..cb7bf81d5 100644 --- a/appengine_jsr107/pom.xml +++ b/appengine_jsr107/pom.xml @@ -24,7 +24,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT diff --git a/appengine_resources/pom.xml b/appengine_resources/pom.xml index 1c23d36c0..20aa62bc6 100644 --- a/appengine_resources/pom.xml +++ b/appengine_resources/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar AppEngine :: appengine-resources diff --git a/appengine_setup/apiserver_local/pom.xml b/appengine_setup/apiserver_local/pom.xml index d0f7ee6bd..96a12368f 100644 --- a/appengine_setup/apiserver_local/pom.xml +++ b/appengine_setup/apiserver_local/pom.xml @@ -20,7 +20,7 @@ com.google.appengine appengine_setup - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT 4.0.0 diff --git a/appengine_setup/pom.xml b/appengine_setup/pom.xml index 49fefe008..8f5cf1637 100644 --- a/appengine_setup/pom.xml +++ b/appengine_setup/pom.xml @@ -24,7 +24,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT apiserver_local diff --git a/appengine_setup/test/pom.xml b/appengine_setup/test/pom.xml index cccbdff75..de457b613 100644 --- a/appengine_setup/test/pom.xml +++ b/appengine_setup/test/pom.xml @@ -20,7 +20,7 @@ com.google.appengine appengine_setup - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT 4.0.0 com.google.appengine diff --git a/appengine_setup/test/src/test/java/com/google/appengine/setup/test/Jetty12TestAppTest.java b/appengine_setup/test/src/test/java/com/google/appengine/setup/test/Jetty12TestAppTest.java index 68aa37c7b..76565eecb 100644 --- a/appengine_setup/test/src/test/java/com/google/appengine/setup/test/Jetty12TestAppTest.java +++ b/appengine_setup/test/src/test/java/com/google/appengine/setup/test/Jetty12TestAppTest.java @@ -26,6 +26,6 @@ protected String appName() { @Override protected String relativePathForUserApplicationJar() { return "../testapps/jetty12_testapp/target/" - + "jetty12_testapp-2.0.32-SNAPSHOT-jar-with-dependencies.jar"; + + "jetty12_testapp-2.0.34-SNAPSHOT-jar-with-dependencies.jar"; } } diff --git a/appengine_setup/test/src/test/java/com/google/appengine/setup/test/SpringBootTestAppTest.java b/appengine_setup/test/src/test/java/com/google/appengine/setup/test/SpringBootTestAppTest.java index e890ccc88..d7716339d 100644 --- a/appengine_setup/test/src/test/java/com/google/appengine/setup/test/SpringBootTestAppTest.java +++ b/appengine_setup/test/src/test/java/com/google/appengine/setup/test/SpringBootTestAppTest.java @@ -25,6 +25,6 @@ protected String appName() { @Override protected String relativePathForUserApplicationJar() { - return "../testapps/springboot_testapp/target/" + "springboot_testapp-2.0.32-SNAPSHOT.jar"; + return "../testapps/springboot_testapp/target/" + "springboot_testapp-2.0.34-SNAPSHOT.jar"; } } diff --git a/appengine_setup/test/src/test/java/com/google/appengine/setup/test/util/TestUtil.java b/appengine_setup/test/src/test/java/com/google/appengine/setup/test/util/TestUtil.java index 349c76046..ce58c595a 100644 --- a/appengine_setup/test/src/test/java/com/google/appengine/setup/test/util/TestUtil.java +++ b/appengine_setup/test/src/test/java/com/google/appengine/setup/test/util/TestUtil.java @@ -62,7 +62,7 @@ public static HttpClient initializeHttpClient(int timeoutMillis) { @SneakyThrows public static Process initializeHttpApiServer() { String apiServerRelativeJarPath = - "../apiserver_local/target/" + "apiserver_local-2.0.32-SNAPSHOT-jar-with-dependencies.jar"; + "../apiserver_local/target/" + "apiserver_local-2.0.34-SNAPSHOT-jar-with-dependencies.jar"; File currentDirectory = new File("").getAbsoluteFile(); File apiServerJar = new File(currentDirectory, apiServerRelativeJarPath); ImmutableList processArgs = ImmutableList.builder() diff --git a/appengine_setup/testapps/jetty12_testapp/pom.xml b/appengine_setup/testapps/jetty12_testapp/pom.xml index ddf33717b..828a4fdd2 100644 --- a/appengine_setup/testapps/jetty12_testapp/pom.xml +++ b/appengine_setup/testapps/jetty12_testapp/pom.xml @@ -20,7 +20,7 @@ testapps com.google.appengine - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT 4.0.0 com.google.appengine.setup.testapps @@ -33,7 +33,7 @@ com.google.appengine.setup.testapps testapps_common - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT org.eclipse.jetty @@ -106,7 +106,7 @@ srirammahavadi-dev GCLOUD_CONFIG true - ${project.build.directory}/jetty11_testapp-2.0.32-SNAPSHOT-jar-with-dependencies.jar + ${project.build.directory}/jetty11_testapp-2.0.34-SNAPSHOT-jar-with-dependencies.jar diff --git a/appengine_setup/testapps/pom.xml b/appengine_setup/testapps/pom.xml index 9d67d4895..f7daa7ed4 100644 --- a/appengine_setup/testapps/pom.xml +++ b/appengine_setup/testapps/pom.xml @@ -20,7 +20,7 @@ com.google.appengine appengine_setup - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT 4.0.0 com.google.appengine diff --git a/appengine_setup/testapps/springboot_testapp/pom.xml b/appengine_setup/testapps/springboot_testapp/pom.xml index 1522bbcba..95f758cda 100644 --- a/appengine_setup/testapps/springboot_testapp/pom.xml +++ b/appengine_setup/testapps/springboot_testapp/pom.xml @@ -25,7 +25,7 @@ com.google.appengine.setup.testapps springboot_testapp - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT springboot_testapp Demo project for Spring Boot @@ -44,12 +44,12 @@ com.google.appengine appengine-api-1.0-sdk - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT com.google.appengine.setup.testapps testapps_common - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/appengine_setup/testapps/testapps_common/pom.xml b/appengine_setup/testapps/testapps_common/pom.xml index 9e465b925..6886ec833 100644 --- a/appengine_setup/testapps/testapps_common/pom.xml +++ b/appengine_setup/testapps/testapps_common/pom.xml @@ -20,7 +20,7 @@ testapps com.google.appengine - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT 4.0.0 com.google.appengine.setup.testapps diff --git a/appengine_testing/pom.xml b/appengine_testing/pom.xml index a819ba2c2..0adb2291d 100644 --- a/appengine_testing/pom.xml +++ b/appengine_testing/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/appengine_testing_tests/pom.xml b/appengine_testing_tests/pom.xml index fb50c526e..ba3adb1d0 100644 --- a/appengine_testing_tests/pom.xml +++ b/appengine_testing_tests/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/applications/pom.xml b/applications/pom.xml index 0cea08ae0..6d3a9e9d4 100644 --- a/applications/pom.xml +++ b/applications/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT pom diff --git a/applications/proberapp/pom.xml b/applications/proberapp/pom.xml index 00f8d418d..e9860c21b 100644 --- a/applications/proberapp/pom.xml +++ b/applications/proberapp/pom.xml @@ -27,7 +27,7 @@ com.google.appengine applications - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT @@ -38,7 +38,7 @@ us-central1 prober-user prober_connectivity_test_database - 2.59.1 + 2.60.0 ${project.version} UTF-8 target/${project.artifactId}-${project.version} @@ -51,14 +51,14 @@ appengine-api-1.0-sdk - jstl + javax.servlet jstl 1.2 com.google.cloud google-cloud-spanner - 6.85.0 + 6.86.0 com.google.appengine @@ -116,27 +116,27 @@ com.google.cloud google-cloud-bigquery - 2.45.0 + 2.47.0 com.google.cloud google-cloud-core - 2.49.1 + 2.50.0 com.google.cloud google-cloud-datastore - 2.25.2 + 2.26.1 com.google.cloud google-cloud-logging - 3.21.0 + 3.21.2 com.google.cloud google-cloud-storage - 2.47.0 + 2.48.1 com.google.cloud.sql @@ -168,9 +168,9 @@ compile - mysql - mysql-connector-java - 8.0.33 + com.mysql + mysql-connector-j + 8.2.0 org.apache.httpcomponents diff --git a/applications/springboot/pom.xml b/applications/springboot/pom.xml index b6595b020..eb1776817 100644 --- a/applications/springboot/pom.xml +++ b/applications/springboot/pom.xml @@ -24,7 +24,7 @@ com.google.appengine applications - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/devappservertests/pom.xml b/e2etests/devappservertests/pom.xml index f133a4571..c4f284e7a 100644 --- a/e2etests/devappservertests/pom.xml +++ b/e2etests/devappservertests/pom.xml @@ -22,7 +22,7 @@ com.google.appengine e2etests - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/e2etests/pom.xml b/e2etests/pom.xml index 59f2599c8..4aa0e05ab 100644 --- a/e2etests/pom.xml +++ b/e2etests/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT AppEngine :: e2e tests pom diff --git a/e2etests/stagingtests/pom.xml b/e2etests/stagingtests/pom.xml index 88456a7f3..9c5b742d3 100644 --- a/e2etests/stagingtests/pom.xml +++ b/e2etests/stagingtests/pom.xml @@ -22,7 +22,7 @@ com.google.appengine e2etests - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/e2etests/testlocalapps/allinone/pom.xml b/e2etests/testlocalapps/allinone/pom.xml index d2288e693..cd1a0bb51 100644 --- a/e2etests/testlocalapps/allinone/pom.xml +++ b/e2etests/testlocalapps/allinone/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/allinone_jakarta/pom.xml b/e2etests/testlocalapps/allinone_jakarta/pom.xml index 04ed3cac7..3c07509f2 100644 --- a/e2etests/testlocalapps/allinone_jakarta/pom.xml +++ b/e2etests/testlocalapps/allinone_jakarta/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/badcron/pom.xml b/e2etests/testlocalapps/badcron/pom.xml index 91c58c20e..9fc01a9f5 100644 --- a/e2etests/testlocalapps/badcron/pom.xml +++ b/e2etests/testlocalapps/badcron/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/bundle_standard/pom.xml b/e2etests/testlocalapps/bundle_standard/pom.xml index aab72f7d0..2beac8627 100644 --- a/e2etests/testlocalapps/bundle_standard/pom.xml +++ b/e2etests/testlocalapps/bundle_standard/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/bundle_standard_with_container_initializer/pom.xml b/e2etests/testlocalapps/bundle_standard_with_container_initializer/pom.xml index 122e7b692..594c8b9b2 100644 --- a/e2etests/testlocalapps/bundle_standard_with_container_initializer/pom.xml +++ b/e2etests/testlocalapps/bundle_standard_with_container_initializer/pom.xml @@ -25,7 +25,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/bundle_standard_with_no_jsp/pom.xml b/e2etests/testlocalapps/bundle_standard_with_no_jsp/pom.xml index e10788c44..e69c2c53b 100644 --- a/e2etests/testlocalapps/bundle_standard_with_no_jsp/pom.xml +++ b/e2etests/testlocalapps/bundle_standard_with_no_jsp/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/bundle_standard_with_weblistener_memcache/pom.xml b/e2etests/testlocalapps/bundle_standard_with_weblistener_memcache/pom.xml index 1564db329..231442d98 100644 --- a/e2etests/testlocalapps/bundle_standard_with_weblistener_memcache/pom.xml +++ b/e2etests/testlocalapps/bundle_standard_with_weblistener_memcache/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/cron-bad-job-age-limit/pom.xml b/e2etests/testlocalapps/cron-bad-job-age-limit/pom.xml index ab4c6b35a..1039ab2e2 100644 --- a/e2etests/testlocalapps/cron-bad-job-age-limit/pom.xml +++ b/e2etests/testlocalapps/cron-bad-job-age-limit/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/cron-good-retry-parameters/pom.xml b/e2etests/testlocalapps/cron-good-retry-parameters/pom.xml index e0602c77e..43b73bbf2 100644 --- a/e2etests/testlocalapps/cron-good-retry-parameters/pom.xml +++ b/e2etests/testlocalapps/cron-good-retry-parameters/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/cron-negative-max-backoff/pom.xml b/e2etests/testlocalapps/cron-negative-max-backoff/pom.xml index 39df02c8d..abe7a84c0 100644 --- a/e2etests/testlocalapps/cron-negative-max-backoff/pom.xml +++ b/e2etests/testlocalapps/cron-negative-max-backoff/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/cron-negative-retry-limit/pom.xml b/e2etests/testlocalapps/cron-negative-retry-limit/pom.xml index 8f2da0217..161f32fa0 100644 --- a/e2etests/testlocalapps/cron-negative-retry-limit/pom.xml +++ b/e2etests/testlocalapps/cron-negative-retry-limit/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/cron-two-max-doublings/pom.xml b/e2etests/testlocalapps/cron-two-max-doublings/pom.xml index 95650f006..0b292ee07 100644 --- a/e2etests/testlocalapps/cron-two-max-doublings/pom.xml +++ b/e2etests/testlocalapps/cron-two-max-doublings/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/http-headers/pom.xml b/e2etests/testlocalapps/http-headers/pom.xml index 76697a313..3bf583081 100644 --- a/e2etests/testlocalapps/http-headers/pom.xml +++ b/e2etests/testlocalapps/http-headers/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/java8-jar/pom.xml b/e2etests/testlocalapps/java8-jar/pom.xml index 64b33bb6e..4a8f410b0 100644 --- a/e2etests/testlocalapps/java8-jar/pom.xml +++ b/e2etests/testlocalapps/java8-jar/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/java8-no-webxml/pom.xml b/e2etests/testlocalapps/java8-no-webxml/pom.xml index 3238f4b55..b16dceb67 100644 --- a/e2etests/testlocalapps/java8-no-webxml/pom.xml +++ b/e2etests/testlocalapps/java8-no-webxml/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/pom.xml b/e2etests/testlocalapps/pom.xml index 6f3f9e334..82fc1ed88 100644 --- a/e2etests/testlocalapps/pom.xml +++ b/e2etests/testlocalapps/pom.xml @@ -22,7 +22,7 @@ com.google.appengine e2etests - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT pom diff --git a/e2etests/testlocalapps/sample-badaeweb/pom.xml b/e2etests/testlocalapps/sample-badaeweb/pom.xml index a847ef0d3..b35ee7de2 100644 --- a/e2etests/testlocalapps/sample-badaeweb/pom.xml +++ b/e2etests/testlocalapps/sample-badaeweb/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-baddispatch-yaml/pom.xml b/e2etests/testlocalapps/sample-baddispatch-yaml/pom.xml index 7a2d68280..54b3cb744 100644 --- a/e2etests/testlocalapps/sample-baddispatch-yaml/pom.xml +++ b/e2etests/testlocalapps/sample-baddispatch-yaml/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-baddispatch/pom.xml b/e2etests/testlocalapps/sample-baddispatch/pom.xml index ea6053297..feb62684c 100644 --- a/e2etests/testlocalapps/sample-baddispatch/pom.xml +++ b/e2etests/testlocalapps/sample-baddispatch/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-badentrypoint/pom.xml b/e2etests/testlocalapps/sample-badentrypoint/pom.xml index 5040dda52..5d01a516b 100644 --- a/e2etests/testlocalapps/sample-badentrypoint/pom.xml +++ b/e2etests/testlocalapps/sample-badentrypoint/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-badindexes/pom.xml b/e2etests/testlocalapps/sample-badindexes/pom.xml index 9fd6ebef8..8534f21e9 100644 --- a/e2etests/testlocalapps/sample-badindexes/pom.xml +++ b/e2etests/testlocalapps/sample-badindexes/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-badruntimechannel/pom.xml b/e2etests/testlocalapps/sample-badruntimechannel/pom.xml index d13da3fbf..7b5e8b1d1 100644 --- a/e2etests/testlocalapps/sample-badruntimechannel/pom.xml +++ b/e2etests/testlocalapps/sample-badruntimechannel/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-badweb/pom.xml b/e2etests/testlocalapps/sample-badweb/pom.xml index 558baae57..da94a6dfd 100644 --- a/e2etests/testlocalapps/sample-badweb/pom.xml +++ b/e2etests/testlocalapps/sample-badweb/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-default-auto-ids/pom.xml b/e2etests/testlocalapps/sample-default-auto-ids/pom.xml index 79107e741..38f3ffed0 100644 --- a/e2etests/testlocalapps/sample-default-auto-ids/pom.xml +++ b/e2etests/testlocalapps/sample-default-auto-ids/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-error-in-tag-file/pom.xml b/e2etests/testlocalapps/sample-error-in-tag-file/pom.xml index 3b7ffaece..cf68242af 100644 --- a/e2etests/testlocalapps/sample-error-in-tag-file/pom.xml +++ b/e2etests/testlocalapps/sample-error-in-tag-file/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-java11/pom.xml b/e2etests/testlocalapps/sample-java11/pom.xml index eed17b572..9c8567c55 100644 --- a/e2etests/testlocalapps/sample-java11/pom.xml +++ b/e2etests/testlocalapps/sample-java11/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-java17/pom.xml b/e2etests/testlocalapps/sample-java17/pom.xml index e4048275d..c0f535006 100644 --- a/e2etests/testlocalapps/sample-java17/pom.xml +++ b/e2etests/testlocalapps/sample-java17/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-jsptaglibrary/pom.xml b/e2etests/testlocalapps/sample-jsptaglibrary/pom.xml index 8c4196df5..36744abdc 100644 --- a/e2etests/testlocalapps/sample-jsptaglibrary/pom.xml +++ b/e2etests/testlocalapps/sample-jsptaglibrary/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-jspx/pom.xml b/e2etests/testlocalapps/sample-jspx/pom.xml index dc15a0459..66aa905f8 100644 --- a/e2etests/testlocalapps/sample-jspx/pom.xml +++ b/e2etests/testlocalapps/sample-jspx/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-legacy-auto-ids/pom.xml b/e2etests/testlocalapps/sample-legacy-auto-ids/pom.xml index 35daba90d..76b7237c7 100644 --- a/e2etests/testlocalapps/sample-legacy-auto-ids/pom.xml +++ b/e2etests/testlocalapps/sample-legacy-auto-ids/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-missingappid/pom.xml b/e2etests/testlocalapps/sample-missingappid/pom.xml index 8b596fa38..1dfd4f616 100644 --- a/e2etests/testlocalapps/sample-missingappid/pom.xml +++ b/e2etests/testlocalapps/sample-missingappid/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-nojsps/pom.xml b/e2etests/testlocalapps/sample-nojsps/pom.xml index 5e9fc0fb4..a24d9ce1d 100644 --- a/e2etests/testlocalapps/sample-nojsps/pom.xml +++ b/e2etests/testlocalapps/sample-nojsps/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-unspecified-auto-ids/pom.xml b/e2etests/testlocalapps/sample-unspecified-auto-ids/pom.xml index bddb1046b..a013c33a8 100644 --- a/e2etests/testlocalapps/sample-unspecified-auto-ids/pom.xml +++ b/e2etests/testlocalapps/sample-unspecified-auto-ids/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sample-with-classes/pom.xml b/e2etests/testlocalapps/sample-with-classes/pom.xml index cd305b0ac..0244375a9 100644 --- a/e2etests/testlocalapps/sample-with-classes/pom.xml +++ b/e2etests/testlocalapps/sample-with-classes/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sampleapp-automatic-module/pom.xml b/e2etests/testlocalapps/sampleapp-automatic-module/pom.xml index 90fbe39cb..377554eb1 100644 --- a/e2etests/testlocalapps/sampleapp-automatic-module/pom.xml +++ b/e2etests/testlocalapps/sampleapp-automatic-module/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sampleapp-backends/pom.xml b/e2etests/testlocalapps/sampleapp-backends/pom.xml index 4d5fad583..b300b6a33 100644 --- a/e2etests/testlocalapps/sampleapp-backends/pom.xml +++ b/e2etests/testlocalapps/sampleapp-backends/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war AppEngine :: sampleapp-backends diff --git a/e2etests/testlocalapps/sampleapp-basic-module/pom.xml b/e2etests/testlocalapps/sampleapp-basic-module/pom.xml index 019ead24f..b7d11ca3c 100644 --- a/e2etests/testlocalapps/sampleapp-basic-module/pom.xml +++ b/e2etests/testlocalapps/sampleapp-basic-module/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sampleapp-manual-module/pom.xml b/e2etests/testlocalapps/sampleapp-manual-module/pom.xml index e39693529..9559a0b5f 100644 --- a/e2etests/testlocalapps/sampleapp-manual-module/pom.xml +++ b/e2etests/testlocalapps/sampleapp-manual-module/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sampleapp-runtime/pom.xml b/e2etests/testlocalapps/sampleapp-runtime/pom.xml index 4a9ed0fcb..e857dccb2 100644 --- a/e2etests/testlocalapps/sampleapp-runtime/pom.xml +++ b/e2etests/testlocalapps/sampleapp-runtime/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/sampleapp/pom.xml b/e2etests/testlocalapps/sampleapp/pom.xml index 3282dbb4c..fe2d2fbbe 100644 --- a/e2etests/testlocalapps/sampleapp/pom.xml +++ b/e2etests/testlocalapps/sampleapp/pom.xml @@ -25,7 +25,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT AppEngine :: sampleapp diff --git a/e2etests/testlocalapps/stage-sampleapp/pom.xml b/e2etests/testlocalapps/stage-sampleapp/pom.xml index 5aa16f8fb..4cec56fba 100644 --- a/e2etests/testlocalapps/stage-sampleapp/pom.xml +++ b/e2etests/testlocalapps/stage-sampleapp/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/stage-with-staging-options/pom.xml b/e2etests/testlocalapps/stage-with-staging-options/pom.xml index 90f3ee2e9..31f46d391 100644 --- a/e2etests/testlocalapps/stage-with-staging-options/pom.xml +++ b/e2etests/testlocalapps/stage-with-staging-options/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war diff --git a/e2etests/testlocalapps/xmlorder/pom.xml b/e2etests/testlocalapps/xmlorder/pom.xml index 0db64b7a0..ecf8adfe6 100644 --- a/e2etests/testlocalapps/xmlorder/pom.xml +++ b/e2etests/testlocalapps/xmlorder/pom.xml @@ -24,7 +24,7 @@ com.google.appengine testlocalapps - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT war AppEngine :: xmlorder diff --git a/external/geronimo_javamail/pom.xml b/external/geronimo_javamail/pom.xml index e665dbd48..c33e81cf3 100644 --- a/external/geronimo_javamail/pom.xml +++ b/external/geronimo_javamail/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT ../../pom.xml diff --git a/google3/third_party/java_src/appengine_standard/api_compatibility_tests/pom.xml b/google3/third_party/java_src/appengine_standard/api_compatibility_tests/pom.xml index d0a14b561..edde84fdb 100644 --- a/google3/third_party/java_src/appengine_standard/api_compatibility_tests/pom.xml +++ b/google3/third_party/java_src/appengine_standard/api_compatibility_tests/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/jetty12_assembly/pom.xml b/jetty12_assembly/pom.xml index c605b8e97..e37bff043 100644 --- a/jetty12_assembly/pom.xml +++ b/jetty12_assembly/pom.xml @@ -20,7 +20,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT 4.0.0 jetty12-assembly diff --git a/lib/pom.xml b/lib/pom.xml index 24931a031..76a22a790 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT pom diff --git a/lib/tools_api/pom.xml b/lib/tools_api/pom.xml index b8193d30e..bd6139a78 100644 --- a/lib/tools_api/pom.xml +++ b/lib/tools_api/pom.xml @@ -23,7 +23,7 @@ com.google.appengine lib-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/lib/xml_validator/pom.xml b/lib/xml_validator/pom.xml index 273e47b79..0fdabaf27 100644 --- a/lib/xml_validator/pom.xml +++ b/lib/xml_validator/pom.xml @@ -22,7 +22,7 @@ com.google.appengine lib-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar AppEngine :: libxmlvalidator diff --git a/lib/xml_validator_test/pom.xml b/lib/xml_validator_test/pom.xml index 18dfbe585..8924f253b 100644 --- a/lib/xml_validator_test/pom.xml +++ b/lib/xml_validator_test/pom.xml @@ -22,7 +22,7 @@ com.google.appengine lib-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar AppEngine :: libxmlvalidator_test diff --git a/local_runtime_shared_jetty12/pom.xml b/local_runtime_shared_jetty12/pom.xml index 156738514..532d75fe9 100644 --- a/local_runtime_shared_jetty12/pom.xml +++ b/local_runtime_shared_jetty12/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar AppEngine :: appengine-local-runtime-shared Jetty12 diff --git a/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java b/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java index f866a198f..c3fc08639 100644 --- a/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java +++ b/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java @@ -23,8 +23,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Map; import java.util.logging.Logger; import javax.servlet.ServletException; @@ -125,23 +123,15 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I final String action = req.getParameter(ACTION_MODULE); if (action != null && moduleName != null && moduleVersion != null) { - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - try { - if (action.equals("Stop")) { - getModulesController().stopModule(moduleName, moduleVersion); - } else if (action.equals("Start")) { - getModulesController().startModule(moduleName, moduleVersion); - } - } catch (Exception e) { - logger.severe( - "Got error when performing a " + action + " of module : " + moduleName); - } - return null; - } - }); + try { + if (action.equals("Stop")) { + getModulesController().stopModule(moduleName, moduleVersion); + } else if (action.equals("Start")) { + getModulesController().startModule(moduleName, moduleVersion); + } + } catch (Exception e) { + logger.severe("Got error when performing a " + action + " of module : " + moduleName); + } } else { logger.severe("The post method against the modules servlet was called without all of the " + "expected post parameters, we got [moduleName = " + moduleName + ", moduleVersion = " + diff --git a/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ee10/ModulesServlet.java b/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ee10/ModulesServlet.java index 7a75b6a40..ed8e7516c 100644 --- a/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ee10/ModulesServlet.java +++ b/local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ee10/ModulesServlet.java @@ -27,8 +27,6 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Map; import java.util.logging.Logger; @@ -125,23 +123,15 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I final String action = req.getParameter(ACTION_MODULE); if (action != null && moduleName != null && moduleVersion != null) { - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - try { - if (action.equals("Stop")) { - getModulesController().stopModule(moduleName, moduleVersion); - } else if (action.equals("Start")) { - getModulesController().startModule(moduleName, moduleVersion); - } - } catch (Exception e) { - logger.severe( - "Got error when performing a " + action + " of module : " + moduleName); - } - return null; - } - }); + try { + if (action.equals("Stop")) { + getModulesController().stopModule(moduleName, moduleVersion); + } else if (action.equals("Start")) { + getModulesController().startModule(moduleName, moduleVersion); + } + } catch (Exception e) { + logger.severe("Got error when performing a " + action + " of module : " + moduleName); + } } else { logger.severe("The post method against the modules servlet was called without all of the " + "expected post parameters, we got [moduleName = " + moduleName + ", moduleVersion = " + diff --git a/local_runtime_shared_jetty9/pom.xml b/local_runtime_shared_jetty9/pom.xml index 372ae5684..753c0bfed 100644 --- a/local_runtime_shared_jetty9/pom.xml +++ b/local_runtime_shared_jetty9/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar AppEngine :: appengine-local-runtime-shared Jetty9 diff --git a/local_runtime_shared_jetty9/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java b/local_runtime_shared_jetty9/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java index f866a198f..3b58f28bc 100644 --- a/local_runtime_shared_jetty9/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java +++ b/local_runtime_shared_jetty9/src/main/java/com/google/apphosting/utils/servlet/ModulesServlet.java @@ -23,8 +23,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Map; import java.util.logging.Logger; import javax.servlet.ServletException; @@ -125,23 +123,16 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I final String action = req.getParameter(ACTION_MODULE); if (action != null && moduleName != null && moduleVersion != null) { - AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - try { - if (action.equals("Stop")) { - getModulesController().stopModule(moduleName, moduleVersion); - } else if (action.equals("Start")) { - getModulesController().startModule(moduleName, moduleVersion); - } - } catch (Exception e) { - logger.severe( - "Got error when performing a " + action + " of module : " + moduleName); - } - return null; - } - }); + try { + if (action.equals("Stop")) { + getModulesController().stopModule(moduleName, moduleVersion); + } else if (action.equals("Start")) { + getModulesController().startModule(moduleName, moduleVersion); + } + } catch (Exception e) { + logger.severe( + "Got error when performing a " + action + " of module : " + moduleName); + } } else { logger.severe("The post method against the modules servlet was called without all of the " + "expected post parameters, we got [moduleName = " + moduleName + ", moduleVersion = " + diff --git a/pom.xml b/pom.xml index 41c175631..d1572dd38 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT pom AppEngine :: Parent project @@ -66,8 +66,8 @@ UTF-8 9.4.57.v20241219 12.0.16 - 1.69.0 - 4.1.116.Final + 1.70.0 + 4.1.118.Final 2.0.16 https://oss.sonatype.org/content/repositories/google-snapshots/ sonatype-nexus-snapshots @@ -325,12 +325,12 @@ com.google.api-client google-api-client-appengine - 2.7.1 + 2.7.2 com.google.api-client google-api-client - 2.7.1 + 2.7.2 com.google.appengine @@ -434,7 +434,7 @@ com.google.code.gson gson - 2.11.0 + 2.12.1 com.google.flogger @@ -460,7 +460,7 @@ com.google.http-client google-http-client - 1.45.3 + 1.46.1 com.google.http-client @@ -537,7 +537,7 @@ org.checkerframework checker-qual - 3.48.4 + 3.49.0 provided @@ -591,7 +591,7 @@ com.google.http-client google-http-client-appengine - 1.45.3 + 1.46.1 com.google.oauth-client @@ -672,7 +672,7 @@ joda-time joda-time - 2.13.0 + 2.13.1 org.json @@ -682,7 +682,7 @@ commons-codec commons-codec - 1.17.2 + 1.18.0 @@ -726,7 +726,7 @@ com.google.cloud google-cloud-logging - 3.21.0 + 3.21.2 diff --git a/protobuf/pom.xml b/protobuf/pom.xml index fe6880eb9..435e73494 100644 --- a/protobuf/pom.xml +++ b/protobuf/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/quickstartgenerator/pom.xml b/quickstartgenerator/pom.xml index d5e674b5e..7044be480 100644 --- a/quickstartgenerator/pom.xml +++ b/quickstartgenerator/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/quickstartgenerator_jetty12/pom.xml b/quickstartgenerator_jetty12/pom.xml index 2cde7ffac..792056091 100644 --- a/quickstartgenerator_jetty12/pom.xml +++ b/quickstartgenerator_jetty12/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/quickstartgenerator_jetty12_ee10/pom.xml b/quickstartgenerator_jetty12_ee10/pom.xml index 7b4b33a70..9dcc83008 100644 --- a/quickstartgenerator_jetty12_ee10/pom.xml +++ b/quickstartgenerator_jetty12_ee10/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/remoteapi/pom.xml b/remoteapi/pom.xml index ff7b7be30..37dc206ff 100644 --- a/remoteapi/pom.xml +++ b/remoteapi/pom.xml @@ -20,7 +20,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar AppEngine :: appengine-remote-api diff --git a/runtime/annotationscanningwebapp/pom.xml b/runtime/annotationscanningwebapp/pom.xml index 9f1232887..9bc760d94 100644 --- a/runtime/annotationscanningwebapp/pom.xml +++ b/runtime/annotationscanningwebapp/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT com.google.appengine.demos annotationscanningwebapp diff --git a/runtime/deployment/pom.xml b/runtime/deployment/pom.xml index 8bc1c1d10..47d1c3805 100644 --- a/runtime/deployment/pom.xml +++ b/runtime/deployment/pom.xml @@ -22,7 +22,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT pom diff --git a/runtime/failinitfilterwebapp/pom.xml b/runtime/failinitfilterwebapp/pom.xml index 349d7c042..25c9b8428 100644 --- a/runtime/failinitfilterwebapp/pom.xml +++ b/runtime/failinitfilterwebapp/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT com.google.appengine.demos failinitfilterwebapp diff --git a/runtime/impl/pom.xml b/runtime/impl/pom.xml index ee7d4b226..4ffddd813 100644 --- a/runtime/impl/pom.xml +++ b/runtime/impl/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/ApiProxyImpl.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/ApiProxyImpl.java index fc3a81a96..8b5d92bc2 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/ApiProxyImpl.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/ApiProxyImpl.java @@ -49,9 +49,6 @@ import com.google.protobuf.ByteString; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.InvalidProtocolBufferException; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.time.Duration; import java.util.Collections; import java.util.HashMap; @@ -289,8 +286,7 @@ public byte[] makeSyncCall( final String packageName, final String methodName, final byte[] request) { - return AccessController.doPrivileged( - (PrivilegedAction) () -> doSyncCall(environment, packageName, methodName, request)); + return doSyncCall(environment, packageName, methodName, request); } @Override @@ -300,9 +296,8 @@ public Future makeAsyncCall( final String methodName, final byte[] request, final ApiProxy.ApiConfig apiConfig) { - return AccessController.doPrivileged( - (PrivilegedAction>) () -> doAsyncCall( - environment, packageName, methodName, request, apiConfig.getDeadlineInSeconds())); + return doAsyncCall( + environment, packageName, methodName, request, apiConfig.getDeadlineInSeconds()); } private byte[] doSyncCall( @@ -1350,7 +1345,7 @@ public void run() { } } - private static PrivilegedAction runWithThreadContext( + private static Runnable runWithThreadContext( Runnable runnable, Environment environment, CloudTraceContext parentThreadContext) { return () -> { CloudTrace.setCurrentContext(environment, parentThreadContext); @@ -1359,7 +1354,6 @@ private static PrivilegedAction runWithThreadContext( } finally { CloudTrace.setCurrentContext(environment, null); } - return null; }; } @@ -1376,16 +1370,10 @@ public Thread newThread(final Runnable runnable) { ThreadGroup requestThreadGroup = environment.getRequestThreadGroup(); RequestState requestState = environment.getRequestState(); - CloudTraceContext parentThreadContext = - CloudTrace.getCurrentContext(environment); - AccessControlContext context = AccessController.getContext(); - Runnable contextRunnable = - () -> - AccessController.doPrivileged( - runWithThreadContext(runnable, environment, parentThreadContext), context); - return AccessController.doPrivileged( - (PrivilegedAction) () -> new CurrentRequestThread( - requestThreadGroup, contextRunnable, runnable, requestState, environment)); + CloudTraceContext parentThreadContext = CloudTrace.getCurrentContext(environment); + Runnable contextRunnable = runWithThreadContext(runnable, environment, parentThreadContext); + return new CurrentRequestThread( + requestThreadGroup, contextRunnable, runnable, requestState, environment); } } @@ -1408,11 +1396,7 @@ public Thread newThread(final Runnable runnable) { CloudTraceContext parentThreadContext = CloudTrace.getCurrentContext(environment); - AccessControlContext context = AccessController.getContext(); - Runnable contextRunnable = - () -> - AccessController.doPrivileged( - runWithThreadContext(runnable, environment, parentThreadContext), context); + Runnable contextRunnable = runWithThreadContext(runnable, environment, parentThreadContext); String requestId = systemService.startBackgroundRequest(); Number deadline = MoreObjects.firstNonNull( diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java index 20758ff75..d32e5c3d0 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java @@ -20,6 +20,16 @@ /** {@code AppEngineConstants} centralizes some constants that are specific to our use of Jetty. */ public final class AppEngineConstants { + + /** + * If Legacy Mode is turned on, then Jetty is configured to be more forgiving of bad requests and + * to act more in the style of Jetty-9.3 + */ + public static final boolean LEGACY_MODE = + Boolean.getBoolean("com.google.apphosting.runtime.jetty94.LEGACY_MODE"); + + public static final String GAE_RUNTIME = System.getenv("GAE_RUNTIME"); + /** * This {@code ServletContext} attribute contains the {@link AppVersion} for the current * application. diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersionFactory.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersionFactory.java index 864beb67a..7215a856a 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersionFactory.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersionFactory.java @@ -35,7 +35,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.lang.Thread.UncaughtExceptionHandler; -import java.lang.reflect.Field; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.FileSystems; @@ -257,7 +256,6 @@ public AppVersion createAppVersion( .setUncaughtExceptionHandler(uncaughtExceptionHandler) .setIgnoreDaemonThreads(ignoreDaemonThreads) .build(); - suppressJaxbWarningReflectionIsNotAllowed(classLoader); setApplicationDirectory(rootDirectory.getAbsolutePath()); return AppVersion.builder() .setAppVersionKey(appVersionKey) @@ -535,35 +533,6 @@ private URL[] getUrls(ClassPathBuilder classPathBuilder) { return urls; } - /** - * Suppresses the warning that JAXB logs when reflection is not allowed on - * a field. - * Most annoyingly, the warning is logged the first time that a JAX-WS service - * class is instantiated, due to the private fields in the - * {@code javax.xml.ws.wsaddressing.W3CEndpointReference} class. - * Since this warning is only logged once, irrespective of the number of class/field - * combinations for which reflection fails, there is little that is lost in - * suppressing it. See b/5609065 for more information. - * - * @param classLoader the application ClassLoader - */ - private void suppressJaxbWarningReflectionIsNotAllowed(ClassLoader classLoader) { - // Suppressing the warning is only meaningful in runtimes that install a security manager. - if (System.getSecurityManager() != null) { - try { - // Must use reflection here because the JAXB implementation classes are - // on the application classpath. - Class accessorClass = - classLoader.loadClass("com.sun.xml.bind.v2.runtime.reflect.Accessor"); - Field accessWarned = accessorClass.getDeclaredField("accessWarned"); - accessWarned.setAccessible(true); - accessWarned.setBoolean(null, true); - } catch (Exception e) { - logger.atWarning().withCause(e).log("failed to suppress JAXB warning reflectively"); - } - } - } - private static void setApplicationDirectory(String path) throws IOException { // Set the (real) "user.dir" system property to the application directory, // so that calls like File.getAbsolutePath() will return the expected path diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java index 3b9fb9cd3..ca4eaa0aa 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java @@ -45,8 +45,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; @@ -588,18 +586,13 @@ public void sendDeadline(RequestToken token, boolean isUncatchable) { } logger.atInfo().log("Stopping request thread."); // Throw the exception in targetThread. - AccessController.doPrivileged( - (PrivilegedAction) () -> { - try { - ThreadStop0Holder.threadStop0.invoke(targetThread, throwable); - } catch (Exception e) { - logger.atWarning().withCause(e).log("Failed to stop thread"); - } - return null; - }); + try { + ThreadStop0Holder.threadStop0.invoke(targetThread, throwable); + } catch (Exception e) { + logger.atWarning().withCause(e).log("Failed to stop thread"); + } } } - } private String threadDump(Collection threads, String prefix) { @@ -900,30 +893,24 @@ public List getRequestThreads(AppVersionKey appVersionKey) { } /** - * Consults {@link ThreadMXBean#findDeadlockedThreads()} to see if - * any deadlocks are currently present. If so, it will - * immediately respond to the runtime and simulate a LOG(FATAL) - * containing the stack trace of the offending threads. + * Consults {@link ThreadMXBean#findDeadlockedThreads()} to see if any deadlocks are currently + * present. If so, it will immediately respond to the runtime and simulate a LOG(FATAL) containing + * the stack trace of the offending threads. */ private void checkForDeadlocks(final RequestToken token) { - AccessController.doPrivileged( - (PrivilegedAction) () -> { - long[] deadlockedThreadsIds = THREAD_MX.findDeadlockedThreads(); - if (deadlockedThreadsIds != null) { - StringBuilder builder = new StringBuilder(); - builder.append( - "Detected a deadlock across " + deadlockedThreadsIds.length + " threads:"); - for (ThreadInfo info : - THREAD_MX.getThreadInfo(deadlockedThreadsIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { - builder.append(info); - builder.append("\n"); - } - String message = builder.toString(); - token.addAppLogMessage(Level.fatal, message); - token.logAndKillRuntime(message); - } - return null; - }); + long[] deadlockedThreadsIds = THREAD_MX.findDeadlockedThreads(); + if (deadlockedThreadsIds != null) { + StringBuilder builder = new StringBuilder(); + builder.append("Detected a deadlock across " + deadlockedThreadsIds.length + " threads:"); + for (ThreadInfo info : + THREAD_MX.getThreadInfo(deadlockedThreadsIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { + builder.append(info); + builder.append("\n"); + } + String message = builder.toString(); + token.addAppLogMessage(Level.fatal, message); + token.logAndKillRuntime(message); + } } private void logMemoryStats() { @@ -934,22 +921,15 @@ private void logMemoryStats() { } private void logAllStackTraces() { - AccessController.doPrivileged( - (PrivilegedAction) - () -> { - long[] allthreadIds = THREAD_MX.getAllThreadIds(); - StringBuilder builder = new StringBuilder(); - builder.append( - "Dumping thread info for all " + allthreadIds.length + " runtime threads:"); - for (ThreadInfo info : - THREAD_MX.getThreadInfo(allthreadIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { - builder.append(info); - builder.append("\n"); - } - String message = builder.toString(); - logger.atInfo().log("%s", message); - return null; - }); + long[] allthreadIds = THREAD_MX.getAllThreadIds(); + StringBuilder builder = new StringBuilder(); + builder.append("Dumping thread info for all " + allthreadIds.length + " runtime threads:"); + for (ThreadInfo info : THREAD_MX.getThreadInfo(allthreadIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { + builder.append(info); + builder.append("\n"); + } + String message = builder.toString(); + logger.atInfo().log("%s", message); } private Throwable createDeadlineThrowable(String message, boolean isUncatchable) { diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestRunner.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestRunner.java index f659142cf..166c7fc8f 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestRunner.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestRunner.java @@ -16,6 +16,7 @@ package com.google.apphosting.runtime; +import static com.google.apphosting.runtime.AppEngineConstants.GAE_RUNTIME; import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.google.appengine.api.ThreadManager; @@ -240,7 +241,7 @@ private void dispatchBackgroundRequest() throws InterruptedException, TimeoutExc String requestId = getBackgroundRequestId(upRequest); // For java21 runtime, RPC path, do the new background thread handling for now, and keep it for // other runtimes. - if (!Objects.equals(System.getenv("GAE_RUNTIME"), "java21")) { + if (!Objects.equals(GAE_RUNTIME, "java21")) { // Wait here for synchronization with the ThreadFactory. CountDownLatch latch = ThreadGroupPool.resetCurrentThread(); Thread thread = new ThreadProxy(); diff --git a/runtime/lite/pom.xml b/runtime/lite/pom.xml index 98c3d91a9..cb7af9477 100644 --- a/runtime/lite/pom.xml +++ b/runtime/lite/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/lite/src/main/java/com/google/appengine/runtime/lite/RequestManager.java b/runtime/lite/src/main/java/com/google/appengine/runtime/lite/RequestManager.java index 6d3837733..1ed7294dd 100644 --- a/runtime/lite/src/main/java/com/google/appengine/runtime/lite/RequestManager.java +++ b/runtime/lite/src/main/java/com/google/appengine/runtime/lite/RequestManager.java @@ -54,8 +54,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; @@ -774,27 +772,22 @@ public List getRequestThreads(AppVersionKey appVersionKey) { * the stack trace of the offending threads. */ private void checkForDeadlocks(final RequestToken token) { - AccessController.doPrivileged( - (PrivilegedAction) - () -> { - long[] deadlockedThreadsIds = THREAD_MX.findDeadlockedThreads(); - if (deadlockedThreadsIds != null) { - StringBuilder builder = new StringBuilder(); - builder.append( - "Detected a deadlock across ") - .append(deadlockedThreadsIds.length) - .append(" threads:"); - for (ThreadInfo info : - THREAD_MX.getThreadInfo(deadlockedThreadsIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { - builder.append(info); - builder.append("\n"); - } - String message = builder.toString(); - token.addAppLogMessage(Level.fatal, message); - token.logAndKillRuntime(message); - } - return null; - }); + long[] deadlockedThreadsIds = THREAD_MX.findDeadlockedThreads(); + if (deadlockedThreadsIds != null) { + StringBuilder builder = new StringBuilder(); + builder + .append("Detected a deadlock across ") + .append(deadlockedThreadsIds.length) + .append(" threads:"); + for (ThreadInfo info : + THREAD_MX.getThreadInfo(deadlockedThreadsIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { + builder.append(info); + builder.append("\n"); + } + String message = builder.toString(); + token.addAppLogMessage(Level.fatal, message); + token.logAndKillRuntime(message); + } } private void logMemoryStats() { @@ -805,24 +798,18 @@ private void logMemoryStats() { } private void logAllStackTraces() { - AccessController.doPrivileged( - (PrivilegedAction) - () -> { - long[] allthreadIds = THREAD_MX.getAllThreadIds(); - StringBuilder builder = new StringBuilder(); - builder - .append("Dumping thread info for all ") - .append(allthreadIds.length) - .append(" runtime threads:"); - for (ThreadInfo info : - THREAD_MX.getThreadInfo(allthreadIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { - builder.append(info); - builder.append("\n"); - } - String message = builder.toString(); - logger.atInfo().log("%s", message); - return null; - }); + long[] allthreadIds = THREAD_MX.getAllThreadIds(); + StringBuilder builder = new StringBuilder(); + builder + .append("Dumping thread info for all ") + .append(allthreadIds.length) + .append(" runtime threads:"); + for (ThreadInfo info : THREAD_MX.getThreadInfo(allthreadIds, MAXIMUM_DEADLOCK_STACK_LENGTH)) { + builder.append(info); + builder.append("\n"); + } + String message = builder.toString(); + logger.atInfo().log("%s", message); } private Throwable createDeadlineThrowable(String message, boolean isUncatchable) { diff --git a/runtime/local_jetty12/pom.xml b/runtime/local_jetty12/pom.xml index 77954412e..7362b65d9 100644 --- a/runtime/local_jetty12/pom.xml +++ b/runtime/local_jetty12/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/local_jetty12/src/main/java/com/google/appengine/tools/development/jetty/JettyContainerService.java b/runtime/local_jetty12/src/main/java/com/google/appengine/tools/development/jetty/JettyContainerService.java index c68ecb602..4ff98f06d 100644 --- a/runtime/local_jetty12/src/main/java/com/google/appengine/tools/development/jetty/JettyContainerService.java +++ b/runtime/local_jetty12/src/main/java/com/google/appengine/tools/development/jetty/JettyContainerService.java @@ -62,9 +62,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.ee8.nested.ContextHandler; -import org.eclipse.jetty.ee8.nested.HandlerWrapper; -import org.eclipse.jetty.ee8.nested.HttpChannel; import org.eclipse.jetty.ee8.nested.Request; +import org.eclipse.jetty.ee8.nested.ScopedHandler; import org.eclipse.jetty.ee8.servlet.ServletHolder; import org.eclipse.jetty.ee8.webapp.Configuration; import org.eclipse.jetty.ee8.webapp.JettyWebXmlConfiguration; @@ -354,7 +353,6 @@ protected void connectContainer() throws Exception { 0, Runtime.getRuntime().availableProcessors(), new HttpConnectionFactory(configuration)); - connector.addBean(new CompletionListener()); connector.setHost(address); connector.setPort(port); // Linux keeps the port blocked after shutdown if we don't disable this. @@ -597,7 +595,7 @@ private File determineAppRoot() throws IOException { * com.google.apphosting.api.ApiProxy.Environment} which is stored as a request Attribute and then * set/cleared on a ThreadLocal by the ContextScopeListener {@link ThreadLocal}. */ - private class ApiProxyHandler extends HandlerWrapper { + private class ApiProxyHandler extends ScopedHandler { @SuppressWarnings("hiding") // Hides AbstractContainerService.appEngineWebXml private final AppEngineWebXml appEngineWebXml; @@ -606,7 +604,103 @@ public ApiProxyHandler(AppEngineWebXml appEngineWebXml) { } @Override - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + public void doHandle( + String target, + Request baseRequest, + HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException { + nextHandle(target, baseRequest, request, response); + } + + @Override + public void doScope( + String target, + Request baseRequest, + HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException { + + org.eclipse.jetty.server.Request.addCompletionListener( + baseRequest.getCoreRequest(), + t -> { + try { + // a special hook with direct access to the container instance + // we invoke this only after the normal request processing, + // in order to generate a valid response + if (request.getRequestURI().startsWith(AH_URL_RELOAD)) { + try { + reloadWebApp(); + log.info("Reloaded the webapp context: " + request.getParameter("info")); + } catch (Exception ex) { + log.log(Level.WARNING, "Failed to reload the current webapp context.", ex); + } + } + } finally { + + LocalEnvironment env = + (LocalEnvironment) request.getAttribute(LocalEnvironment.class.getName()); + if (env != null) { + environments.remove(env); + + // Acquire all of the semaphores back, which will block if any are outstanding. + Semaphore semaphore = + (Semaphore) env.getAttributes().get(LocalEnvironment.API_CALL_SEMAPHORE); + try { + System.err.println("=========== acquire semaphore ==========="); + semaphore.acquire(MAX_SIMULTANEOUS_API_CALLS); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + log.log( + Level.WARNING, "Interrupted while waiting for API calls to complete:", ex); + } + + try { + ApiProxy.setEnvironmentForCurrentThread(env); + + // Invoke all of the registered RequestEndListeners. + env.callRequestEndListeners(); + + if (apiProxyDelegate instanceof ApiProxyLocal) { + // If apiProxyDelegate is not instanceof ApiProxyLocal, we are presumably + // running in + // the devappserver2 environment, where the master web server in Python will + // take care + // of logging requests. + ApiProxyLocal apiProxyLocal = (ApiProxyLocal) apiProxyDelegate; + String appId = env.getAppId(); + String versionId = env.getVersionId(); + String requestId = DevLogHandler.getRequestId(); + + LocalLogService logService = + (LocalLogService) apiProxyLocal.getService(LocalLogService.PACKAGE); + + @SuppressWarnings("NowMillis") + long nowMillis = System.currentTimeMillis(); + logService.addRequestInfo( + appId, + versionId, + requestId, + request.getRemoteAddr(), + request.getRemoteUser(), + baseRequest.getTimeStamp() * 1000, + nowMillis * 1000, + request.getMethod(), + request.getRequestURI(), + request.getProtocol(), + request.getHeader("User-Agent"), + true, + response.getStatus(), + request.getHeader("Referrer")); + logService.clearResponseSize(); + } + } finally { + ApiProxy.clearEnvironmentForCurrentThread(); + } + } + } + }); + if (baseRequest.getDispatcherType() == DispatcherType.REQUEST) { Semaphore semaphore = new Semaphore(MAX_SIMULTANEOUS_API_CALLS); @@ -631,87 +725,9 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques // this and so the Environment has not yet been created. ApiProxy.Environment oldEnv = enterScope(request); try { - super.handle(target, baseRequest, request, response); - } - finally { - exitScope(oldEnv); - } - } - } - - private class CompletionListener implements HttpChannel.Listener { - @Override - public void onComplete(Request request) { - try { - // a special hook with direct access to the container instance - // we invoke this only after the normal request processing, - // in order to generate a valid response - if (request.getRequestURI().startsWith(AH_URL_RELOAD)) { - try { - reloadWebApp(); - log.info("Reloaded the webapp context: " + request.getParameter("info")); - } catch (Exception ex) { - log.log(Level.WARNING, "Failed to reload the current webapp context.", ex); - } - } + super.doScope(target, baseRequest, request, response); } finally { - - LocalEnvironment env = - (LocalEnvironment) request.getAttribute(LocalEnvironment.class.getName()); - if (env != null) { - environments.remove(env); - - // Acquire all of the semaphores back, which will block if any are outstanding. - Semaphore semaphore = - (Semaphore) env.getAttributes().get(LocalEnvironment.API_CALL_SEMAPHORE); - try { - semaphore.acquire(MAX_SIMULTANEOUS_API_CALLS); - } catch (InterruptedException ex) { - Thread.currentThread().interrupt(); - log.log(Level.WARNING, "Interrupted while waiting for API calls to complete:", ex); - } - - try { - ApiProxy.setEnvironmentForCurrentThread(env); - - // Invoke all of the registered RequestEndListeners. - env.callRequestEndListeners(); - - if (apiProxyDelegate instanceof ApiProxyLocal) { - // If apiProxyDelegate is not instanceof ApiProxyLocal, we are presumably running in - // the devappserver2 environment, where the master web server in Python will take care - // of logging requests. - ApiProxyLocal apiProxyLocal = (ApiProxyLocal) apiProxyDelegate; - String appId = env.getAppId(); - String versionId = env.getVersionId(); - String requestId = DevLogHandler.getRequestId(); - - LocalLogService logService = - (LocalLogService) apiProxyLocal.getService(LocalLogService.PACKAGE); - - @SuppressWarnings("NowMillis") - long nowMillis = System.currentTimeMillis(); - logService.addRequestInfo( - appId, - versionId, - requestId, - request.getRemoteAddr(), - request.getRemoteUser(), - request.getTimeStamp() * 1000, - nowMillis * 1000, - request.getMethod(), - request.getRequestURI(), - request.getProtocol(), - request.getHeader("User-Agent"), - true, - request.getResponse().getStatus(), - request.getHeader("Referrer")); - logService.clearResponseSize(); - } - } finally { - ApiProxy.clearEnvironmentForCurrentThread(); - } - } + exitScope(oldEnv); } } } diff --git a/runtime/local_jetty12_ee10/pom.xml b/runtime/local_jetty12_ee10/pom.xml index 7fa2a17de..8d4573749 100644 --- a/runtime/local_jetty12_ee10/pom.xml +++ b/runtime/local_jetty12_ee10/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/local_jetty9/pom.xml b/runtime/local_jetty9/pom.xml index 12dedcb3c..9ba271d54 100644 --- a/runtime/local_jetty9/pom.xml +++ b/runtime/local_jetty9/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/main/pom.xml b/runtime/main/pom.xml index bf541d25b..c3917a69e 100644 --- a/runtime/main/pom.xml +++ b/runtime/main/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/nogaeapiswebapp/pom.xml b/runtime/nogaeapiswebapp/pom.xml index fb3e72549..6bf17cd9a 100644 --- a/runtime/nogaeapiswebapp/pom.xml +++ b/runtime/nogaeapiswebapp/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT com.google.appengine.demos nogaeapiswebapp diff --git a/runtime/pom.xml b/runtime/pom.xml index b164eb117..a5600b8ad 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT AppEngine :: runtime projects pom diff --git a/runtime/runtime_impl_jetty12/pom.xml b/runtime/runtime_impl_jetty12/pom.xml index 44b459462..a95822e6c 100644 --- a/runtime/runtime_impl_jetty12/pom.xml +++ b/runtime/runtime_impl_jetty12/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/AppVersionHandlerFactory.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/AppVersionHandlerFactory.java index b85e50e3b..c616bc219 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/AppVersionHandlerFactory.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/AppVersionHandlerFactory.java @@ -22,11 +22,28 @@ import org.eclipse.jetty.server.Server; public interface AppVersionHandlerFactory { + + enum EEVersion + { + EE8, + EE10 + } + + static EEVersion getEEVersion() { + if (Boolean.getBoolean("appengine.use.EE10")) + return EEVersion.EE10; + else + return EEVersion.EE8; + } + static AppVersionHandlerFactory newInstance(Server server, String serverInfo) { - if (Boolean.getBoolean("appengine.use.EE10")) { - return new EE10AppVersionHandlerFactory(server, serverInfo); - } else { - return new EE8AppVersionHandlerFactory(server, serverInfo); + switch (getEEVersion()) { + case EE10: + return new EE10AppVersionHandlerFactory(server, serverInfo); + case EE8: + return new EE8AppVersionHandlerFactory(server, serverInfo); + default: + throw new IllegalStateException("Unknown EE version: " + getEEVersion()); } } diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/JettyServletEngineAdapter.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/JettyServletEngineAdapter.java index 129da7f33..d4e54a72d 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/JettyServletEngineAdapter.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/JettyServletEngineAdapter.java @@ -15,8 +15,10 @@ */ package com.google.apphosting.runtime.jetty; +import static com.google.apphosting.runtime.AppEngineConstants.GAE_RUNTIME; import static com.google.apphosting.runtime.AppEngineConstants.HTTP_CONNECTOR_MODE; import static com.google.apphosting.runtime.AppEngineConstants.IGNORE_RESPONSE_SIZE_LIMIT; +import static com.google.apphosting.runtime.AppEngineConstants.LEGACY_MODE; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.apphosting.api.ApiProxy; @@ -45,14 +47,13 @@ import java.util.Objects; import java.util.concurrent.ExecutionException; import org.eclipse.jetty.http.CookieCompliance; +import org.eclipse.jetty.http.HttpCompliance; +import org.eclipse.jetty.http.MultiPartCompliance; import org.eclipse.jetty.http.UriCompliance; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.SizeLimitHandler; +import org.eclipse.jetty.server.handler.SizeLimitHandler; import org.eclipse.jetty.util.VirtualThreads; -import org.eclipse.jetty.util.resource.Resource; -import org.eclipse.jetty.util.resource.ResourceFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; /** @@ -65,13 +66,6 @@ public class JettyServletEngineAdapter implements ServletEngineAdapter { private static final int MAX_THREAD_POOL_THREADS = 100; private static final long MAX_RESPONSE_SIZE = 32 * 1024 * 1024; - /** - * If Legacy Mode is turned on, then Jetty is configured to be more forgiving of bad requests and - * to act more in the style of Jetty-9.3 - */ - public static final boolean LEGACY_MODE = - Boolean.getBoolean("com.google.apphosting.runtime.jetty94.LEGACY_MODE"); - private AppVersionKey lastAppVersionKey; static { @@ -108,7 +102,7 @@ public void start(String serverInfo, ServletEngineAdapter.Config runtimeOptions) new QueuedThreadPool(MAX_THREAD_POOL_THREADS, MIN_THREAD_POOL_THREADS); // Try to enable virtual threads if requested and on java21: if (Boolean.getBoolean("appengine.use.virtualthreads") - && "java21".equals(System.getenv("GAE_RUNTIME"))) { + && "java21".equals(GAE_RUNTIME)) { threadPool.setVirtualThreadsExecutor(VirtualThreads.getDefaultVirtualThreadsExecutor()); logger.atInfo().log("Configuring Appengine web server virtual threads."); } @@ -138,10 +132,18 @@ public void run(Runnable runnable) { httpConfiguration.setSendDateHeader(false); httpConfiguration.setSendServerVersion(false); httpConfiguration.setSendXPoweredBy(false); + + // If runtime is using EE8, then set URI compliance to LEGACY to behave like Jetty 9.4. + if (Objects.equals(AppVersionHandlerFactory.getEEVersion(), AppVersionHandlerFactory.EEVersion.EE8)) { + httpConfiguration.setUriCompliance(UriCompliance.LEGACY); + } + if (LEGACY_MODE) { + httpConfiguration.setUriCompliance(UriCompliance.LEGACY); + httpConfiguration.setHttpCompliance(HttpCompliance.RFC7230_LEGACY); httpConfiguration.setRequestCookieCompliance(CookieCompliance.RFC2965); httpConfiguration.setResponseCookieCompliance(CookieCompliance.RFC2965); - httpConfiguration.setUriCompliance(UriCompliance.LEGACY); + httpConfiguration.setMultiPartCompliance(MultiPartCompliance.LEGACY); } server.addConnector(rpcConnector); diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/impl/DelegateRpcExchange.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/impl/DelegateRpcExchange.java index 57c39d21c..afee2b2f4 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/impl/DelegateRpcExchange.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/impl/DelegateRpcExchange.java @@ -16,6 +16,8 @@ package com.google.apphosting.runtime.jetty.delegate.impl; +import static com.google.apphosting.runtime.AppEngineConstants.LEGACY_MODE; + import com.google.apphosting.base.protos.HttpPb; import com.google.apphosting.base.protos.HttpPb.ParsedHttpHeader; import com.google.apphosting.base.protos.RuntimePb; @@ -23,26 +25,23 @@ import com.google.apphosting.runtime.jetty.delegate.api.DelegateExchange; import com.google.common.base.Ascii; import com.google.protobuf.ByteString; -import org.eclipse.jetty.http.HttpFields; -import org.eclipse.jetty.http.HttpMethod; -import org.eclipse.jetty.io.ByteBufferAccumulator; -import org.eclipse.jetty.io.Content; -import org.eclipse.jetty.util.Attributes; -import org.eclipse.jetty.util.Callback; - import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jetty.http.HttpFields; +import org.eclipse.jetty.http.HttpMethod; +import org.eclipse.jetty.io.ByteBufferAccumulator; +import org.eclipse.jetty.io.Content; +import org.eclipse.jetty.util.Attributes; +import org.eclipse.jetty.util.Callback; public class DelegateRpcExchange implements DelegateExchange { private static final Content.Chunk EOF = Content.Chunk.EOF; private static final String X_GOOGLE_INTERNAL_SKIPADMINCHECK = "x-google-internal-skipadmincheck"; private static final String SKIP_ADMIN_CHECK_ATTR = "com.google.apphosting.internal.SkipAdminCheck"; - static final boolean LEGACY_MODE = - Boolean.getBoolean("com.google.apphosting.runtime.jetty94.LEGACY_MODE"); private final HttpPb.HttpRequest _request; private final AtomicReference _content = new AtomicReference<>(); diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/AppEngineWebAppContext.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/AppEngineWebAppContext.java index e4b59617f..42d9391f9 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/AppEngineWebAppContext.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/AppEngineWebAppContext.java @@ -21,6 +21,7 @@ import com.google.apphosting.api.ApiProxy; import com.google.apphosting.api.ApiProxy.LogRecord; +import com.google.apphosting.runtime.AppEngineConstants; import com.google.apphosting.runtime.jetty.EE10AppEngineAuthentication; import com.google.apphosting.utils.servlet.ee10.DeferredTaskServlet; import com.google.apphosting.utils.servlet.ee10.JdbcMySqlConnectionCleanupFilter; @@ -278,6 +279,9 @@ public boolean handle(Request request, Response response, Callback callback) thr protected ServletHandler newServletHandler() { ServletHandler handler = new ServletHandler(); handler.setAllowDuplicateMappings(true); + if (AppEngineConstants.LEGACY_MODE) { + handler.setDecodeAmbiguousURIs(true); + } return handler; } diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java index 93c4f42d9..3f6877323 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee10/ResourceFileServlet.java @@ -16,8 +16,8 @@ package com.google.apphosting.runtime.jetty.ee10; -import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.runtime.AppEngineConstants; +import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.utils.config.AppYaml; import com.google.common.base.Ascii; import com.google.common.flogger.GoogleLogger; @@ -27,6 +27,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URL; +import java.util.Objects; import org.eclipse.jetty.ee10.servlet.ServletContextHandler; import org.eclipse.jetty.ee10.servlet.ServletHandler; import org.eclipse.jetty.ee10.servlet.ServletMapping; @@ -36,9 +39,6 @@ import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceFactory; -import java.io.IOException; -import java.util.Objects; - /** * {@code ResourceFileServlet} is a copy of {@code org.mortbay.jetty.servlet.DefaultServlet} that * has been trimmed down to only support the subset of features that we want to take advantage of @@ -88,9 +88,8 @@ public void init() throws ServletException { defaultServletName = servletMapping.getServletName(); try { - // TODO: review use of root factory. - resourceBase = - ResourceFactory.root().newResource(context.getResource("/" + appVersion.getPublicRoot())); + URL resourceBaseUrl = context.getResource("/" + appVersion.getPublicRoot()); + resourceBase = (resourceBaseUrl == null) ? null : ResourceFactory.of(chandler).newResource(resourceBaseUrl); } catch (Exception ex) { throw new ServletException(ex); } diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java index f79c6ded5..ca06e911a 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/ee8/ResourceFileServlet.java @@ -16,12 +16,13 @@ package com.google.apphosting.runtime.jetty.ee8; -import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.runtime.AppEngineConstants; +import com.google.apphosting.runtime.AppVersion; import com.google.apphosting.utils.config.AppYaml; import com.google.common.base.Ascii; import com.google.common.flogger.GoogleLogger; import java.io.IOException; +import java.net.URL; import java.util.Objects; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; @@ -30,8 +31,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.ee8.nested.ContextHandler; +import org.eclipse.jetty.ee8.servlet.ServletContextHandler; import org.eclipse.jetty.ee8.servlet.ServletHandler; -import org.eclipse.jetty.http.pathmap.MappedResource; +import org.eclipse.jetty.ee8.servlet.ServletMapping; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.resource.Resource; @@ -57,8 +59,9 @@ public class ResourceFileServlet extends HttpServlet { private Resource resourceBase; private String[] welcomeFiles; private FileSender fSender; - ContextHandler chandler; + ServletContextHandler chandler; ServletContext context; + String defaultServletName; /** * Initialize the servlet by extracting some useful configuration data from the current {@link @@ -69,7 +72,7 @@ public void init() throws ServletException { context = getServletContext(); AppVersion appVersion = (AppVersion) context.getAttribute(AppEngineConstants.APP_VERSION_CONTEXT_ATTR); - chandler = ContextHandler.getContextHandler(context); + chandler = ServletContextHandler.getServletContextHandler(context); AppYaml appYaml = (AppYaml) chandler.getServer().getAttribute(AppEngineConstants.APP_YAML_ATTRIBUTE_TARGET); @@ -78,9 +81,15 @@ public void init() throws ServletException { // we access Jetty's internal state. welcomeFiles = chandler.getWelcomeFiles(); + ServletMapping servletMapping = chandler.getServletHandler().getServletMapping("/"); + if (servletMapping == null) { + throw new ServletException("No servlet mapping found"); + } + defaultServletName = servletMapping.getServletName(); + try { - // TODO: review use of root factory. - resourceBase = ResourceFactory.root().newResource(context.getResource("/" + appVersion.getPublicRoot())); + URL resourceBaseUrl = context.getResource("/" + appVersion.getPublicRoot()); + resourceBase = (resourceBaseUrl == null) ? null : ResourceFactory.of(chandler).newResource(resourceBaseUrl); } catch (Exception ex) { throw new ServletException(ex); } @@ -254,13 +263,12 @@ private boolean maybeServeWelcomeFile( (AppVersion) getServletContext().getAttribute(AppEngineConstants.APP_VERSION_CONTEXT_ATTR); ServletHandler handler = chandler.getChildHandlerByClass(ServletHandler.class); - MappedResource defaultEntry = handler.getHolderEntry("/"); - for (String welcomeName : welcomeFiles) { String welcomePath = path + welcomeName; String relativePath = welcomePath.substring(1); - if (!Objects.equals(handler.getHolderEntry(welcomePath), defaultEntry)) { + ServletHandler.MappedServlet mappedServlet = handler.getMappedServlet(welcomePath); + if (!Objects.equals(mappedServlet.getServletHolder().getName(), defaultServletName)) { // It's a path mapped to a servlet. Forward to it. RequestDispatcher dispatcher = request.getRequestDispatcher(path + welcomeName); return serveWelcomeFileAsForward(dispatcher, included, request, response); diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/proxy/JettyHttpProxy.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/proxy/JettyHttpProxy.java index 24f8bce26..a913f4b69 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/proxy/JettyHttpProxy.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/proxy/JettyHttpProxy.java @@ -20,21 +20,24 @@ import com.google.apphosting.base.protos.RuntimePb; import com.google.apphosting.base.protos.RuntimePb.UPRequest; import com.google.apphosting.base.protos.RuntimePb.UPResponse; +import com.google.apphosting.runtime.AppEngineConstants; import com.google.apphosting.runtime.LocalRpcContext; import com.google.apphosting.runtime.ServletEngineAdapter; import com.google.apphosting.runtime.anyrpc.EvaluationRuntimeServerInterface; import com.google.apphosting.runtime.jetty.AppInfoFactory; -import com.google.apphosting.runtime.jetty.JettyServletEngineAdapter; +import com.google.apphosting.runtime.jetty.AppVersionHandlerFactory; import com.google.common.base.Ascii; import com.google.common.base.Throwables; import com.google.common.flogger.GoogleLogger; import com.google.common.primitives.Ints; import java.time.Duration; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.logging.Level; import org.eclipse.jetty.http.CookieCompliance; import org.eclipse.jetty.http.HttpCompliance; +import org.eclipse.jetty.http.MultiPartCompliance; import org.eclipse.jetty.http.UriCompliance; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; @@ -47,8 +50,6 @@ import org.eclipse.jetty.server.handler.gzip.GzipHandler; import org.eclipse.jetty.util.Callback; -import static com.google.apphosting.runtime.AppEngineConstants.IGNORE_RESPONSE_SIZE_LIMIT; - /** * A Jetty web server handling HTTP requests on a given port and forwarding them via gRPC to the * Java8 App Engine runtime implementation. The deployed application is assumed to be located in a @@ -95,11 +96,18 @@ public static ServerConnector newConnector( HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration(); - if (JettyServletEngineAdapter.LEGACY_MODE) { + + // If runtime is using EE8, then set URI compliance to LEGACY to behave like Jetty 9.4. + if (Objects.equals(AppVersionHandlerFactory.getEEVersion(), AppVersionHandlerFactory.EEVersion.EE8)) { + config.setUriCompliance(UriCompliance.LEGACY); + } + + if (AppEngineConstants.LEGACY_MODE) { + config.setUriCompliance(UriCompliance.LEGACY); config.setHttpCompliance(HttpCompliance.RFC7230_LEGACY); config.setRequestCookieCompliance(CookieCompliance.RFC2965); config.setResponseCookieCompliance(CookieCompliance.RFC2965); - config.setUriCompliance(UriCompliance.LEGACY); + config.setMultiPartCompliance(MultiPartCompliance.LEGACY); } config.setRequestHeaderSize(runtimeOptions.jettyRequestHeaderSize()); diff --git a/runtime/runtime_impl_jetty9/pom.xml b/runtime/runtime_impl_jetty9/pom.xml index fb85f6e10..50c2eabb3 100644 --- a/runtime/runtime_impl_jetty9/pom.xml +++ b/runtime/runtime_impl_jetty9/pom.xml @@ -23,7 +23,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/AppEngineWebAppContext.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/AppEngineWebAppContext.java index 52608a60d..8fb0866f8 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/AppEngineWebAppContext.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/AppEngineWebAppContext.java @@ -16,6 +16,7 @@ package com.google.apphosting.runtime.jetty9; +import static com.google.apphosting.runtime.AppEngineConstants.GAE_RUNTIME; import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR; import static java.nio.charset.StandardCharsets.UTF_8; @@ -79,8 +80,7 @@ public class AppEngineWebAppContext extends WebAppContext { private static final int MAX_RESPONSE_SIZE = 32 * 1024 * 1024; private static final boolean APP_IS_ASYNC = Boolean.getBoolean(RpcConnection.ASYNC_ENABLE_PPROPERTY); - private static final boolean IS_JAVA_8_RUNTIME = - Objects.equals(System.getenv("GAE_RUNTIME"), "java8"); + private static final boolean IS_JAVA_8_RUNTIME = Objects.equals(GAE_RUNTIME, "java8"); private static final ImmutableSet EMPTY_SET = ImmutableSet.builder().build(); diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyHttpProxy.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyHttpProxy.java index cb1768b06..226bd7a27 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyHttpProxy.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyHttpProxy.java @@ -16,6 +16,8 @@ package com.google.apphosting.runtime.jetty9; +import static com.google.apphosting.runtime.AppEngineConstants.LEGACY_MODE; + import com.google.apphosting.base.protos.AppLogsPb; import com.google.apphosting.base.protos.RuntimePb; import com.google.apphosting.base.protos.RuntimePb.UPRequest; @@ -93,7 +95,7 @@ public static ServerConnector newConnector( HttpConnectionFactory factory = connector.getConnectionFactory(HttpConnectionFactory.class); factory.setHttpCompliance( - RpcConnector.LEGACY_MODE ? HttpCompliance.RFC7230_LEGACY : HttpCompliance.RFC7230); + LEGACY_MODE ? HttpCompliance.RFC7230_LEGACY : HttpCompliance.RFC7230); HttpConfiguration config = factory.getHttpConfiguration(); config.setRequestHeaderSize(runtimeOptions.jettyRequestHeaderSize()); diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyServletEngineAdapter.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyServletEngineAdapter.java index 97ddcc7c5..629a8c19d 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyServletEngineAdapter.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyServletEngineAdapter.java @@ -16,6 +16,7 @@ package com.google.apphosting.runtime.jetty9; +import static com.google.apphosting.runtime.AppEngineConstants.GAE_RUNTIME; import static com.google.apphosting.runtime.AppEngineConstants.HTTP_CONNECTOR_MODE; import static com.google.apphosting.runtime.AppEngineConstants.IGNORE_RESPONSE_SIZE_LIMIT; import static java.nio.charset.StandardCharsets.UTF_8; @@ -63,7 +64,7 @@ public class JettyServletEngineAdapter implements ServletEngineAdapter { // java.util.logging) instead of writing to System.err // Documentation: http://www.eclipse.org/jetty/documentation/current/configuring-logging.html System.setProperty("org.eclipse.jetty.util.log.class", JettyLogger.class.getName()); - if (Objects.equals(System.getenv("GAE_RUNTIME"), "java8")) { + if (Objects.equals(GAE_RUNTIME, "java8")) { // Remove internal URLs. System.setProperty("java.vendor.url", ""); System.setProperty("java.vendor.url.bug", ""); @@ -118,7 +119,7 @@ public void start(String serverInfo, ServletEngineAdapter.Config runtimeOptions) server.setHandler(appVersionHandlerMap); boolean ignoreResponseSizeLimit = - Objects.equals(System.getenv("GAE_RUNTIME"), "java8") + Objects.equals(GAE_RUNTIME, "java8") || Boolean.getBoolean(IGNORE_RESPONSE_SIZE_LIMIT); if (!ignoreResponseSizeLimit && !isHttpConnectorMode) { server.insertHandler(new SizeLimitHandler(-1, MAX_RESPONSE_SIZE)); diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnection.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnection.java index e69f7797d..acb273e5f 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnection.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnection.java @@ -16,6 +16,9 @@ package com.google.apphosting.runtime.jetty9; +import static com.google.apphosting.runtime.AppEngineConstants.GAE_RUNTIME; +import static com.google.apphosting.runtime.AppEngineConstants.LEGACY_MODE; + import com.google.apphosting.base.AppVersionKey; import com.google.apphosting.base.protos.HttpPb.HttpRequest; import com.google.apphosting.base.protos.HttpPb.ParsedHttpHeader; @@ -70,7 +73,7 @@ public class RpcConnection implements Connection, HttpTransport { Boolean.parseBoolean( System.getProperty( "com.google.appengine.nomalize_inet_addr", - Boolean.toString(!"java8".equals(System.getenv("GAE_RUNTIME"))))); + Boolean.toString(!"java8".equals(GAE_RUNTIME)))); private final List listeners = new CopyOnWriteArrayList<>(); private final RpcConnector connector; @@ -180,7 +183,7 @@ public void onCompleted() { // pretend to parse the request line // LEGACY_MODE is case insensitive for known methods - HttpMethod method = RpcConnector.LEGACY_MODE + HttpMethod method = LEGACY_MODE ? HttpMethod.INSENSITIVE_CACHE.get(rpc.getProtocol()) : HttpMethod.CACHE.get(rpc.getProtocol()); String methodS = method != null ? method.asString() : rpc.getProtocol(); @@ -201,7 +204,7 @@ public void onCompleted() { HttpField field = getField(header); // Handle LegacyMode Headers - if (RpcConnector.LEGACY_MODE && field.getHeader() != null) { + if (LEGACY_MODE && field.getHeader() != null) { switch (field.getHeader()) { case CONTENT_ENCODING: continue; @@ -281,7 +284,7 @@ public void onCompleted() { // enable it only for non java8 runtimes. if ((exception == null) && (abortedError != null) - && !"java8".equals(System.getenv("GAE_RUNTIME"))) { + && !"java8".equals(GAE_RUNTIME)) { exception = abortedError; } diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnector.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnector.java index be32d4e08..6efcab5e5 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnector.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcConnector.java @@ -16,10 +16,11 @@ package com.google.apphosting.runtime.jetty9; +import static com.google.apphosting.runtime.AppEngineConstants.LEGACY_MODE; + import com.google.apphosting.base.AppVersionKey; import com.google.apphosting.base.protos.RuntimePb.UPRequest; import com.google.apphosting.runtime.MutableUpResponse; -import com.google.apphosting.runtime.jetty9.RpcEndPoint; import java.io.IOException; import javax.servlet.ServletException; import org.eclipse.jetty.http.CookieCompliance; @@ -50,14 +51,6 @@ public class RpcConnector extends AbstractConnector { private final HttpConfiguration httpConfiguration = new HttpConfiguration(); - /** - * If Legacy Mode is tunred on, then Jetty is configured to be more forgiving of bad requests - * and to act more in the style of Jetty-9.3 - */ - // Keep this public property name, do not change to jetty9 as it is public contract. - static final boolean LEGACY_MODE = - Boolean.getBoolean("com.google.apphosting.runtime.jetty94.LEGACY_MODE"); // Keep 94 name. - public RpcConnector(Server server) { super(server, null, null, null, 0, new RpcConnectionFactory()); diff --git a/runtime/test/pom.xml b/runtime/test/pom.xml index 8977ba918..821923edc 100644 --- a/runtime/test/pom.xml +++ b/runtime/test/pom.xml @@ -22,7 +22,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/testapps/pom.xml b/runtime/testapps/pom.xml index 98ebe5ef5..267f6835a 100644 --- a/runtime/testapps/pom.xml +++ b/runtime/testapps/pom.xml @@ -22,7 +22,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime/util/pom.xml b/runtime/util/pom.xml index b9b9a8c37..a8d46e334 100644 --- a/runtime/util/pom.xml +++ b/runtime/util/pom.xml @@ -22,7 +22,7 @@ com.google.appengine runtime-parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime_shared/pom.xml b/runtime_shared/pom.xml index 8af67827c..d3e91a68e 100644 --- a/runtime_shared/pom.xml +++ b/runtime_shared/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime_shared/src/main/java/com/google/appengine/api/LifecycleManager.java b/runtime_shared/src/main/java/com/google/appengine/api/LifecycleManager.java index 29380badd..489ae1ca1 100644 --- a/runtime_shared/src/main/java/com/google/appengine/api/LifecycleManager.java +++ b/runtime_shared/src/main/java/com/google/appengine/api/LifecycleManager.java @@ -17,8 +17,6 @@ package com.google.appengine.api; import com.google.apphosting.api.ApiProxy; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -55,23 +53,14 @@ public synchronized void setShutdownHook(ShutdownHook hook) { hooks.put(currentAppVersionId(), hook); } - /** - * Calls Thread.interrupt() on all threads running requests for this - * application. - */ + /** Calls Thread.interrupt() on all threads running requests for this application. */ public void interruptAllRequests() { - AccessController.doPrivileged( - new PrivilegedAction() { - @Override public Void run() { - List threads = ApiProxy.getRequestThreads(); - if (threads != null) { - for (Thread thread : threads) { - thread.interrupt(); - } - } - return null; - } - }); + List threads = ApiProxy.getRequestThreads(); + if (threads != null) { + for (Thread thread : threads) { + thread.interrupt(); + } + } } /** diff --git a/runtime_shared_jetty12/pom.xml b/runtime_shared_jetty12/pom.xml index 2677acce9..e188115f8 100644 --- a/runtime_shared_jetty12/pom.xml +++ b/runtime_shared_jetty12/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime_shared_jetty12_ee10/pom.xml b/runtime_shared_jetty12_ee10/pom.xml index 3d4b84dcf..91c097a70 100644 --- a/runtime_shared_jetty12_ee10/pom.xml +++ b/runtime_shared_jetty12_ee10/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/runtime_shared_jetty9/pom.xml b/runtime_shared_jetty9/pom.xml index 5e7d54b71..357096f17 100644 --- a/runtime_shared_jetty9/pom.xml +++ b/runtime_shared_jetty9/pom.xml @@ -22,7 +22,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/sdk_assembly/pom.xml b/sdk_assembly/pom.xml index 5a378974c..18eebe1b1 100644 --- a/sdk_assembly/pom.xml +++ b/sdk_assembly/pom.xml @@ -20,7 +20,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT 4.0.0 appengine-java-sdk diff --git a/sessiondata/pom.xml b/sessiondata/pom.xml index a75558a97..6c673485d 100644 --- a/sessiondata/pom.xml +++ b/sessiondata/pom.xml @@ -23,7 +23,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/shared_sdk/pom.xml b/shared_sdk/pom.xml index 8651478cc..e0b244e0e 100644 --- a/shared_sdk/pom.xml +++ b/shared_sdk/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/shared_sdk/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java b/shared_sdk/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java index 8595b59d6..6adfc047c 100644 --- a/shared_sdk/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java +++ b/shared_sdk/src/main/java/com/google/apphosting/runtime/SessionManagerUtil.java @@ -26,8 +26,6 @@ import java.io.ObjectStreamClass; import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; @@ -52,12 +50,8 @@ public static Object deserialize(byte[] bytes) { // N.B.: There is most likely user code on the stack // here, but because the value we're returning is not related to // our ClassLoader we'll fail the - // RuntimePermission("getClassLoader") check. We do have this - // permission though, so use a doPrivileged block to get user code - // off the stack. - ClassLoader classLoader = - AccessController.doPrivileged( - (PrivilegedAction) () -> Thread.currentThread().getContextClassLoader()); + // RuntimePermission("getClassLoader") check. + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // TODO: It seems strange that we need to do this. It // would be safer and cleaner if we could find a way to have user // code initiate this serialization, rather than having diff --git a/shared_sdk_jetty12/pom.xml b/shared_sdk_jetty12/pom.xml index 226f8e532..15090f490 100644 --- a/shared_sdk_jetty12/pom.xml +++ b/shared_sdk_jetty12/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/shared_sdk_jetty9/pom.xml b/shared_sdk_jetty9/pom.xml index 415c76344..bb5dd6690 100644 --- a/shared_sdk_jetty9/pom.xml +++ b/shared_sdk_jetty9/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT jar diff --git a/utils/pom.xml b/utils/pom.xml index 914c82613..e56e42bbf 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -21,7 +21,7 @@ com.google.appengine parent - 2.0.32-SNAPSHOT + 2.0.34-SNAPSHOT true