Skip to content

Commit

Permalink
Upgrade to Spring Boot 3.0.0 (#1287)
Browse files Browse the repository at this point in the history
* applied `boot-autoconfiguration-update`

* extract sleuth dependency from spring-cloud-dependencies to io.micrometer dependency

* add jakarta dependency

* extends crud repository for sorting repositories

* remove joda time and ThreeTenBackport

* remove deprecated method `getPersistentEntityTypes`

* add sleuth starter dependency since it's not included in spring cloud dependencies

* add dependencies for micrometer tracing

* upgrade java in maven plugin to 17

* remove transitive dependencies

* fix broken unit tests

* remove sleuth starter dependency

* add io.micrometer dependency

* refacter test class

* remove BraveHttpConfiguration as it is deprecated

* add actuator starter dependency

* remove BraveHttpConfiguration

* fix broken unit tests

* remove usage of a deprecated constructor

* code refactor

* remove the usage of a deprecated constructor

* refactor tests

* change to functional programming model

* remove deprecated class in comments

* fix broken unit tests

* rebase

* fix broken unit testd

* rebase

* change extended binding properties tests according to spring style

* improve line coverage

* update errorprone to 2.16

* refactor code

* fix broken tests

* log nested exception message explicitly

* refactor test code

* remove deprecated class `ClassTypeInformation`

* fix broken unit test

* remove usage of `ClassTypeInformation.class`

* add generics so that unit tests can pass

* change name of an overridden method: `getPersistentEntityTypeInformation`

* fix broken unit test

* remove spring native support module

* replace javax to jakarta

* change package for `LocalServerPort`

* remove deprecated class `WebSecurityConfigurerAdapter`

* implement new auto configuration style

* experiment with samples

* merge dependencies pom

* change sampling property

* exclude `ZipkinAutoConfiguration`

* add firestore transaction manager

* change org of `r2dbc-postgresql`

* update spring-shell-starter to 3.0.0-M1

* refactor datastore basic example

* polish datastore example

* change table name

* change java version in ci

* update failsafe plugin to 3.0.0-M7

* remove java 8 and 11

* remove unused import

* change javadoc plugin source

* fix checkstyle error

* upgrade javadoc plugin source to 17

* upgrade spring boot to 3.0.0-RC2

* upgrade spring boot to 3.0.0-RC2 in samples

* fix spanner repository sample

* refactor pubsub example

* remove `ListenableFuture` as it is deprecated

* remove `ListenableFuture` in samples

* remove `ListenableFuture` in bigquery module

* remove `ListenableFuture` in bigquery sample

* add return in `whenComplete` method

* fix bigquery integration tests

* add `BinderFactoryAutoConfiguration`

* rebase branch onto main

* fix integration tests in kotlin example

* upgrade spring-cloud-dependencies to 2022.0.0-RC2

* upgrade spring-cloud-dependencies-parent to 4.0.0-M5

* fix pubsub stream dead letter sample

* remove `ArgumentCaptor`

* fix `testProducerAndConsumerCustomizers`

* fix bigquery sample integration tests

* remove SpanCustomizer as it is provided by Spring

* refactor code

* remove `GcpSecretManagerBootstrapConfiguration`

* fix integration test in pubsub bus sample

* polish smell code

* remove `createSubscriberStub` method as it is deprecated

* upgrade to spring boot 3.0

* upgrade spring-boot-starter-parent to 3.0.0

* temporily fix integration test in trace sample

* remove errorprone_java8

* add spring aop dependency

* add`ObservedAspect` bean to enable `Observed` annotation

* fix integration test in trace samples

* fix broken tests

* change package

* add param to fix integration tests

* change variable name for `r2dbc-mysql` dependency

* remove deprecated `BigQueryTemplate` constructors

* remove deprecated `SpannerPersistentEntityImpl` method

* remove deprecated `getSubscriber` method

* remove deprecated `computeSubscriberFlowControlSettings` method

* remove deprecated `computeSubscriberRetrySettings` method

* remove deprecated constructor

* remove used private method

* remove deprecated methods

* remove deprecated method

* remove deprecated `getUpdateTime` method

* fix broken tests

* change `getModified` to return milliseconds rather than seconds

* polish

* improve test coverage

* delete the mysql r2dbc sample from samples module

* remove mysql r2dbc support

* upgrade r2dbc-postgresql to 1.0.0

* polish

* fix broken unit test

* improve line coverage

* change lastModifed to return milliseconds

* improve test coverage

* improve test coverage

* improve test coverage

* upgrade `spring-cloud-dependencies-parent` to `4.0.0-RC3`

* restore kotlin sample to use mysql instance

* add java 19 support for unit tests

* remove unused beans in trace

* remove `ListenableFuture` in vision

* fix integration test in vision

* remove unused import

* upgrade to newest version

* restore version

* remove `StackdriverHttpRequestParser`

* update docs of secret manager

* turn off `CanIgnoreReturnValue` in errorprone

* implement new auto configuration style

* order configuration files

* remove r2dbc-mysql starter and sample

* remove `ListenableFuture` in docs

* remove `ListenableFuture` in comments

* remove legacy pubsub stream examples

* remove r2dbc-mysql in docs

* fix smell code

* restore change

* restore dir in docs

* remove unused import

* upgrade kotlin version to 1.7.21

* fix stream docs

* refactor test code

* refactor test code

* remove graalvm in github workflow

* remove sleuth in docs and comments

* change errorprone java baseline to 17

* polish code

* change version to 4.0

* renew copyright

* remove parent in dependencies pom

* remove experimental dependencies

* change spring cloud dependencies to 2022.0

* upgrade spring-cloud-config dependency to 4.0.0

* remove spring milestone repo in production

* change datastore basic example to web-based app

* remove spring native version num

* restore version-update tag

* restore dependency format

* restore dependency format

* restore serialized page test

* modify changlog

* add versions.txt

* delete native support test in samples

* add migration guide

* remove trash files

* change to one sentence per line

* add migration guide (markdown format)

* add link to migration guides

* remove cross references

* specify min java version

* restructure sections

* restore maven-resources-plugin version
  • Loading branch information
JoeWang1127 authored Jan 19, 2023
1 parent 12021ca commit 0caa9b6
Show file tree
Hide file tree
Showing 356 changed files with 2,861 additions and 4,719 deletions.
20 changes: 2 additions & 18 deletions .github/workflows/integrationTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,10 @@ jobs:
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d' --utc)"
- uses: actions/checkout@v2
- name: Setup Java 11
- name: Setup Java 17
uses: actions/setup-java@v1
if: matrix.it != 'native'
with:
java-version: 11
- name: Setup GraalVM
uses: DeLaGuardo/setup-graalvm@4.0
if: matrix.it == 'native' # note that this is no longer in the matrix
with:
graalvm: '21.2.0'
java: 'java11'
arch: 'amd64'
- name: Install GraalVM Native Image
if: matrix.it == 'native'
run: gu install native-image
- uses: actions/cache@v2
id: mvn-cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.date }}
java-version: 17
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v0
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unitTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [8, 11, 17]
java: [17, 19]
steps:
- name: Get current date
id: date
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:

- uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- uses: actions/cache@v2
id: mvn-cache
Expand Down
1 change: 1 addition & 0 deletions .kokoro/publish_javadoc11.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ sudo pandoc \
docs/src/main/md/kotlin.md \
docs/src/main/md/configuration.md \
docs/src/main/md/migration-guide-1.x.md \
docs/src/main/md/migration-guide-3.x.md \
-t markdown_github -o docs/src/main/md/documentation.md

# copy and replace {project-version} documentation
Expand Down
92 changes: 90 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,103 @@ refer to the [commit
history](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/commits/main)
on GitHub.

## 4.0.0

### Generals
This release officially introduces Spring Boot 3.x compatibility. Note that breaking changes occur in this release.

All changes within one large [Pull Request](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/pull/1287) as we think split PRs may bring compatibility issues. For the rational of each change, please refer to the description of the PR.

### Important version upgrades
* Minimum Java version: Java 17
* Spring Framework libraries upgrade
- [Spring Boot 3.0](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide)
- [Spring Framework 6.0](https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x)
- [Spring Cloud 2022.0](https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2022.0-Release-Notes)
* Upgrade plugin versions
* [Enable auto-configuration](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files)
* Fix [#1294](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/1294)

### Bigquery
* Remove deprecated methods
* Replace `ListenableFuture` and `SettableListenableFuture` with `CompletableFuture`
* Code polish
* Improve code coverage

### Cloud SQL
* Remove support for `r2dbc-mysql`
* Fix [#1200](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/1200)

### Datastore
* Remove deprecated methods and constructors
* Replace `ClassTypeInformation` with `TypeInformation`
* Extend inheritance of `DatastoreRepository`
* Change datastore-basic-sample to a web application to remove `spring-shell` dependency
* Fix broken tests
* Code polish

### Firestore
* Replace `ClassTypeInformation` with `TypeInformation`
* Code polish

### Kotlin sample
* Code polish

### Logging
* Replace `javax.servlet` with `jakarta.servlet`
* Remove deprecated methods
* Code polish

### Native support
* Delete the module

### Pubsub
* Replace `ListenableFuture` and `SettableListenableFuture` with `CompletableFuture`
* Remove deprecated methods and constructors
* Code polish

### Pubsub-stream-binder
* Change to functional programming model
* Change `spring-cloud-stream-binder-test` to `spring-cloud-stream-test-support`
* Fix broken tests

### Secret Manager
* Delete `GcpSecretManagerBootstrapConfiguration`

### Security
* Replace `javax.servlet` with `jakarta.servlet`

### Spanner
* Replace `PreferredConstructor` with `InstanceCreatorMetadata`
* Replace `ClassTypeInformation` with `TypeInformation`
* Remove deprecated methods and constructors
* Extend inheritance of `SpannerRepository`
* Fix broken tests
* Code polish

### Storage
* Remove deprecated methods
* Code polish
* Improve code coverage

### Trace
* Remove `spring-cloud-sleuth` dependency
* Instrument trace using Observation API
* Remove deprecated methods
* Fix broken tests

### Vision
* Replace `ListenableFuture` and `SettableListenableFuture` with `CompletableFuture`
* Fix broken tests
* Code polish

## [3.4.2](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/compare/v3.4.1...v3.4.2) (2023-01-18)


### Documentation

* Fixes docs related to keeping a background user thread - pub/sub ([2802b8e](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/commit/2802b8e4dd22dadb9643efe73bca3615435ac362))

## 3.5.0-SNAPSHOT

## 3.4.0

### General
Expand Down
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Currently, this repository provides support for:
** link:spring-cloud-gcp-starters/spring-cloud-gcp-starter-sql-mysql[Google Cloud SQL MySQL]
** link:spring-cloud-gcp-starters/spring-cloud-gcp-starter-sql-postgresql[Google Cloud SQL PostgreSQL]
** link:spring-cloud-gcp-starters/spring-cloud-gcp-starter-storage[Google Cloud Storage]
** link:spring-cloud-gcp-starters/spring-cloud-gcp-starter-trace[Google Cloud Trace with Spring Cloud Sleuth]
** link:spring-cloud-gcp-starters/spring-cloud-gcp-starter-secretmanager[Google Secret Manager]
** link:spring-cloud-gcp-starters/spring-cloud-gcp-starter-security-firebase[Firebase Authentication]
** link:spring-cloud-gcp-starters/spring-cloud-gcp-starter-security-iap[Google Cloud IAP Authentication]
Expand All @@ -55,6 +54,7 @@ This project has dependency and transitive dependencies on Spring Projects. The

|2.0.x |https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2020.0-Release-Notes[2020.0.x] (3.0/Illford) |2.4.x, 2.5.x|5.3.x| No
|3.x | https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2021.0-Release-Notes[2021.0.x] (3.1/Jubilee) |2.6.x, 2.7.x | 5.3.x| Yes
|4.x | https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2022.0-Release-Notes[2022.0.x] (4.0/Kilburn) |https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Release-Notes[3.x]| https://github.com/spring-projects/spring-framework/wiki/What%27s-New-in-Spring-Framework-6.x[6.x]| Yes
|===

== Spring Initializr
Expand All @@ -77,7 +77,7 @@ This will allow you to not specify versions for any of the Maven dependencies an
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>3.4.0</version>
<version>4.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>Spring Framework on Google Cloud Documentation</name>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-docs</artifactId>
<version>3.4.3-SNAPSHOT</version><!-- {x-version-update:spring-cloud-gcp:current} -->
<version>4.0.0-SNAPSHOT</version><!-- {x-version-update:spring-cloud-gcp:current} -->
<packaging>pom</packaging>

<properties>
Expand Down
10 changes: 5 additions & 5 deletions docs/src/main/asciidoc/bigquery.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Below is a code snippet of how to load a CSV data `InputStream` to a BigQuery ta
BigQueryTemplate bigQueryTemplate;
public void loadData(InputStream dataInputStream, String tableName) {
ListenableFuture<Job> bigQueryJobFuture =
CompletableFuture<Job> bigQueryJobFuture =
bigQueryTemplate.writeDataToTable(
tableName,
dataFile.getInputStream(),
Expand All @@ -111,7 +111,7 @@ BigQueryTemplate bigQueryTemplate;
*/
public void loadJsonStream(String tableName, InputStream jsonInputStream)
throws ExecutionException, InterruptedException {
ListenableFuture<WriteApiResponse> writeApFuture =
CompletableFuture<WriteApiResponse> writeApFuture =
bigQueryTemplate.writeJsonStream(tableName, jsonInputStream);
WriteApiResponse apiRes = writeApFuture.get();//get the WriteApiResponse
if (!apiRes.isSuccessful()){
Expand Down Expand Up @@ -139,7 +139,7 @@ BigQueryTemplate bigQueryTemplate;
*/
public void createTableAndloadJsonStream(String tableName, InputStream jsonInputStream, Schema tableSchema)
throws ExecutionException, InterruptedException {
ListenableFuture<WriteApiResponse> writeApFuture =
CompletableFuture<WriteApiResponse> writeApFuture =
bigQueryTemplate.writeJsonStream(tableName, jsonInputStream, tableSchema);//using the overloaded method which created the table when tableSchema is passed
WriteApiResponse apiRes = writeApFuture.get();//get the WriteApiResponse
if (!apiRes.isSuccessful()){
Expand Down Expand Up @@ -200,12 +200,12 @@ Alternatively, you may omit these headers and explicitly set the table name or f
After the `BigQueryFileMessageHandler` processes a message to load data to your BigQuery table, it will respond with a `Job` on the reply channel.
The https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/bigquery/package-summary.html[Job object] provides metadata and information about the load file operation.

By default, the `BigQueryFileMessageHandler` is run in asynchronous mode, with `setSync(false)`, and it will reply with a `ListenableFuture<Job>` on the reply channel.
By default, the `BigQueryFileMessageHandler` is run in asynchronous mode, with `setSync(false)`, and it will reply with a `CompletableFuture<Job>` on the reply channel.
The future is tied to the status of the data loading job and will complete when the job completes.

If the handler is run in synchronous mode with `setSync(true)`, then the handler will block on the completion of the loading job and block until it is complete.

NOTE: If you decide to use Spring Integration Gateways and you wish to receive `ListenableFuture<Job>` as a reply object in the Gateway, you will have to call `.setAsyncExecutor(null)` on your `GatewayProxyFactoryBean`.
NOTE: If you decide to use Spring Integration Gateways and you wish to receive `CompletableFuture<Job>` as a reply object in the Gateway, you will have to call `.setAsyncExecutor(null)` on your `GatewayProxyFactoryBean`.
This is needed to indicate that you wish to reply on the built-in async support rather than rely on async handling of the gateway.

=== Sample
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/first-page.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Spring Framework on Google Cloud lets you leverage the power and simplicity of t
- Map objects, relationships, and collections with Spring Data Cloud Spanner, Spring Data Cloud Datastore and Spring Data Reactive Repositories for Cloud Firestore
- Write and read from Spring Resources backed up by Google Cloud Storage
- Exchange messages with Spring Integration using Google Cloud Pub/Sub on the background
- Trace the execution of your app with Spring Cloud Sleuth and Google Cloud Trace
- Trace the execution of your app with Micrometer and Google Cloud Trace
- Configure your app with Spring Cloud Config, backed up by the Google Runtime Configuration API
- Consume and produce Google Cloud Storage data via Spring Integration GCS Channel Adapters
- Use Spring Security via Google Cloud IAP
Expand Down
4 changes: 3 additions & 1 deletion docs/src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Spring Framework on Google Cloud lets you leverage the power and simplicity of t
- Map objects, relationships, and collections with Spring Data Cloud Spanner, Spring Data Cloud Datastore and Spring Data Reactive Repositories for Cloud Firestore
- Write and read from Spring Resources backed up by Google Cloud Storage
- Exchange messages with Spring Integration using Google Cloud Pub/Sub on the background
- Trace the execution of your app with Spring Cloud Sleuth and Google Cloud Trace
- Trace the execution of your app with Micrometer and Google Cloud Trace
- Configure your app with Spring Cloud Config, backed up by the Google Runtime Configuration API
- Consume and produce Google Cloud Storage data via Spring Integration GCS Channel Adapters
- Use Spring Security via Google Cloud IAP
Expand Down Expand Up @@ -74,3 +74,5 @@ include::kotlin.adoc[]
To see the list of all Google Cloud related configuration properties please check link:appendix.html[the Appendix page].

include::migration-guide-1.x.adoc[]

include::migration-guide-3.x.adoc[]
10 changes: 5 additions & 5 deletions docs/src/main/asciidoc/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ dependencies {
https://cloud.google.com/logging/[Cloud Logging] is the managed logging service provided by Google Cloud.

This module provides support for associating a web request trace ID with the corresponding log entries.
It does so by retrieving the `X-B3-TraceId` value from the https://logback.qos.ch/manual/mdc.html[Mapped Diagnostic Context (MDC)], which is set by Spring Cloud Sleuth.
If Spring Cloud Sleuth isn't used, the configured `TraceIdExtractor` extracts the desired header value and sets it as the log entry's trace ID.
It does so by retrieving the `X-B3-TraceId` value from the https://logback.qos.ch/manual/mdc.html[Mapped Diagnostic Context (MDC)], which is set by Micrometer.
If Micrometer isn't used, the configured `TraceIdExtractor` extracts the desired header value and sets it as the log entry's trace ID.
This allows grouping of log messages by request, for example, in the https://console.cloud.google.com/logs/viewer[Google Cloud Console Logs viewer].

NOTE: Due to the way logging is set up, the Google Cloud project ID and credentials defined in `application.properties` are ignored.
Expand All @@ -35,12 +35,12 @@ You can do this easily if you're using the https://cloud.google.com/sdk[Google C

For use in Web MVC-based applications, `TraceIdLoggingWebMvcInterceptor` is provided that extracts the request trace ID from an HTTP request using a `TraceIdExtractor` and stores it in a thread-local, which can then be used in a logging appender to add the trace ID metadata to log messages.

WARNING: If Spring Framework on Google Cloud Trace is enabled, the logging module disables itself and delegates log correlation to Spring Cloud Sleuth.
WARNING: If Spring Framework on Google Cloud Trace is enabled, the logging module disables itself and delegates log correlation to Micrometer.

`LoggingWebMvcConfigurer` configuration class is also provided to help register the `TraceIdLoggingWebMvcInterceptor` in Spring MVC applications.

Applications hosted on the Google Cloud include trace IDs under the `x-cloud-trace-context` header, which will be included in log entries.
However, if Sleuth is used the trace ID will be picked up from the MDC.
However, if Micrometer is used the trace ID will be picked up from the MDC.

=== Logback Support

Expand Down Expand Up @@ -141,7 +141,7 @@ If `projectId` is not set and cannot be determined, then it'll log `traceId` wit
| `includeLevel` | `true` | Should the severity be included
| `includeThreadName` | `true` | Should the thread name be included
| `includeMDC` | `true` | Should all MDC properties be included.
The MDC properties `X-B3-TraceId`, `X-B3-SpanId` and `X-Span-Export` provided by Spring Sleuth will get excluded as they get handled separately
The MDC properties `X-B3-TraceId`, `X-B3-SpanId` and `X-Span-Export` provided by Micrometer will get excluded as they get handled separately
| `includeLoggerName` | `true` | Should the name of the logger be included
| `includeFormattedMessage` | `true` | Should the formatted log message be included.
| `includeExceptionInMessage` | `true` | Should the stacktrace be appended to the formatted log message.
Expand Down
Loading

0 comments on commit 0caa9b6

Please sign in to comment.