Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore: move GAE java8 runtime to latest (java21) #9882

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
/speech @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/talent @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/texttospeech @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/translate @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/translate @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-ml-translate-dev
/video @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/vision @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers

Expand Down
7 changes: 0 additions & 7 deletions .kokoro/tests/run_prptst_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,4 @@ else
echo -e "\n Testing completed.\n"
fi

# If this is a periodic build, send the test log to the FlakyBot except for Java 8
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
if [[ $JAVA_VERSION != "1.8" && $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
fi

exit $RTN
7 changes: 0 additions & 7 deletions .kokoro/tests/run_test_java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,4 @@ if [[ "$file" == *"run/"* && ("$file" != *"run/filesystem"* && "$file" != *"run/
fi
fi

# If this is a periodic build, send the test log to the FlakyBot except for Java 8
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
if [[ $JAVA_VERSION != "1.8" && $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
fi

exit $RTN
6 changes: 3 additions & 3 deletions appengine-java8/README.md → appengine-java21/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Google App Engine Standard Environment Samples for Java 8
# Google App Engine Standard Environment Samples for Java 21

<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java8/README.md">
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java21/README.md">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>

This is a repository that contains Java code samples for [Google App Engine
Expand Down Expand Up @@ -43,7 +43,7 @@ access control, billing, and services.
This sample demonstrates how to deploy an application on Google App Engine.

- [Documentation][ae-docs]
- [Code](https://github.com/GoogleCloudPlatform/getting-started-java/tree/main/appengine-standard-java8/helloworld)
- [Code](https://github.com/GoogleCloudPlatform/getting-started-java/tree/main/appengine-standard-java21/helloworld)

### Sending Email

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Google Analytics sample for Google App Engine

<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java8/analytics/README.md">
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java21/analytics/README.md">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>

Integrating App Engine with Google Analytics.
Expand All @@ -14,7 +14,7 @@ and set it as an environment variable in [`appengine-web.xml`](src/main/webapp/W

## Running locally
This example uses the
[Maven Cloud SDK based plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven).
[Maven Cloud CLI based plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven).
To run this sample locally:

$ mvn appengine:run
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2017 Google Inc.
Copyright 2024 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.example.appengine</groupId>
<artifactId>appengine-analytics-j8</artifactId>
<artifactId>appengine-analytics-j21</artifactId>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 Google Inc.
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- [START_EXCLUDE] -->
<!--
Copyright 2015 Google Inc.
Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand All @@ -14,9 +14,14 @@
-->
<!-- [END_EXCLUDE] -->
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
<env-variables>

<runtime>java21</runtime>
<app-engine-apis>true</app-engine-apis>
<system-properties>
<property name="appengine.use.EE8" value="true"/>
</system-properties>

<env-variables>
<env-var name="GA_TRACKING_ID" value="YOUR-GA-TRACKING-ID" />
</env-variables>
</appengine-web-app>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- [START_EXCLUDE] -->
<!--
Copyright 2015 Google Inc.
Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# App Identity sample for Google App Engine

<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java8/appidentity/README.md">
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java21/appidentity/README.md">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>


Expand All @@ -12,7 +12,7 @@ Engine][ae-docs].

## Running locally
This example uses the
[Maven Cloud SDK based plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven).
[Maven Cloud CLI based plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven).
To run this sample locally:

$ mvn appengine:run
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2015 Google Inc.
Copyright 2024 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.example.appengine</groupId>
<artifactId>appengine-appidentity-j8</artifactId>
<artifactId>appengine-appidentity-j21</artifactId>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 Google Inc.
* Copyright 2015 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,13 +16,15 @@

package com.example.appengine.appidentity;

import com.google.apphosting.api.ApiProxy;
import java.io.IOException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.apphosting.api.ApiProxy;

@SuppressWarnings("serial")
// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
@WebServlet(
Expand All @@ -32,6 +34,7 @@
)
public class IdentityServlet extends HttpServlet {

// [START gae_java21_app_identity_versioned_hostnames]
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
Expand All @@ -40,4 +43,5 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc
resp.getWriter()
.println(env.getAttributes().get("com.google.appengine.runtime.default_version_hostname"));
}
// [END gae_java21_app_identity_versioned_hostnames]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc.
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,7 +54,7 @@ public SignForAppServlet() {
appIdentity = AppIdentityServiceFactory.getAppIdentityService();
}

// [START gae_java8_app_identity_other_services]
// [START gae_java21_app_identity_other_services]
// Note that the algorithm used by AppIdentity.signForApp() and
// getPublicCertificatesForApp() is "SHA256withRSA"

Expand Down Expand Up @@ -102,7 +102,7 @@ private String simulateIdentityAssertion()
"isValid=%b for message: %s\n\tsignature: %s\n\tpublic cert: %s",
isValid, message, Arrays.toString(blobSignature), Arrays.toString(publicCert));
}
// [END gae_java8_app_identity_other_services]
// [END gae_java21_app_identity_other_services]

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc.
* Copyright 2016 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,22 +16,24 @@

package com.example.appengine.appidentity;

import com.google.appengine.api.appidentity.AppIdentityService;
import com.google.appengine.api.appidentity.AppIdentityServiceFactory;
import com.google.common.io.CharStreams;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

import org.json.JSONObject;
import org.json.JSONTokener;

import com.google.appengine.api.appidentity.AppIdentityService;
import com.google.appengine.api.appidentity.AppIdentityServiceFactory;
import com.google.common.io.CharStreams;

@SuppressWarnings("serial")
class UrlShortener {
// [START gae_java8_app_identity_google_apis]
// [START gae_java21_app_identity_google_apis]

/**
* Returns a shortened URL by calling the Google URL Shortener API.
Expand Down Expand Up @@ -74,5 +76,5 @@ public String createShortUrl(String longUrl) throws Exception {
}
}
}
// [END gae_java8_app_identity_google_apis]
// [END gae_java21_app_identity_google_apis]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc.
* Copyright 2016 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">

<runtime>java21</runtime>
<app-engine-apis>true</app-engine-apis>
<system-properties>
<property name="appengine.use.EE8" value="true"/>
</system-properties>

</appengine-web-app>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 Google Inc.
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Google Inc.
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java8/bigquery/README.md">
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java21/bigquery/README.md">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>

# Google Cloud API Showcase: BigQuery & Cloud Monitoring in App Engine standard environment for Java 8
# Google Cloud API Showcase: BigQuery & Cloud Monitoring in App Engine standard environment for Java 21

This API Showcase demonstrates how to run an App Engine standard environment application with dependencies on both
[Google BigQuery][bigquery] and [StackDriver Monitoring][monitoring].
Expand All @@ -16,11 +16,11 @@ The home page also provides a summary view of the metrics that have been logged

## Clone the sample app

Copy the sample apps to your local machine, and cd to the `appengine-java8/bigquery` directory:
Copy the sample apps to your local machine, and cd to the `appengine-java21/bigquery` directory:

```
git clone https://github.com/GoogleCloudPlatform/java-docs-samples
cd appengine-java8/bigquery
cd appengine-java21/bigquery
```

## Setup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2018 Google Inc.
Copyright 2018 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.example.appengine</groupId>
<artifactId>appengine-bigquery-monitoring-j8</artifactId>
<artifactId>appengine-bigquery-monitoring-j21</artifactId>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google Inc.
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google Inc.
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google Inc.
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google Inc.
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,15 +16,16 @@

package com.example.appengine.bigquerylogging;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.monitoring.v3.Point;
import com.google.monitoring.v3.TimeSeries;
import com.google.protobuf.Timestamp;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public abstract class TimeSeriesSummary<T> {
private String name;
Expand Down
Loading
Loading