Commit Graph

1445 Commits

Author SHA1 Message Date
Johannes Frohnmeyer 57b2e54b5a
Escape current character output
ci/woodpecker/push/woodpecker Pipeline was successful Details
2024-03-12 13:19:48 +01:00
Johannes Frohnmeyer ff4b1a7656
Merge remote-tracking branch 'origin/main'
# Conflicts:
#	.github/ISSUE_TEMPLATE/config.yml
#	.github/dependabot.yml
#	.github/pull_request_template.md
#	.github/workflows/build.yml
#	.github/workflows/check-android-compatibility.yml
#	.github/workflows/check-api-compatibility.yml
#	.github/workflows/cifuzz.yml
#	.github/workflows/codeql-analysis.yml
#	extras/pom.xml
#	extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java
#	extras/src/main/java/com/google/gson/graph/GraphAdapterBuilder.java
#	extras/src/main/java/com/google/gson/interceptors/Intercept.java
#	extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java
#	extras/src/main/java/com/google/gson/interceptors/JsonPostDeserializer.java
#	extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java
#	extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java
#	extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
#	extras/src/test/java/com/google/gson/graph/GraphAdapterBuilderTest.java
#	extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
#	extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
#	extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java
#	extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java
#	graal-native-image-test/pom.xml
#	graal-native-image-test/src/test/java/com/google/gson/native_test/Java17RecordReflectionTest.java
#	graal-native-image-test/src/test/java/com/google/gson/native_test/ReflectionTest.java
#	gson/pom.xml
#	gson/src/main/java/com/google/gson/Gson.java
#	gson/src/main/java/com/google/gson/GsonBuilder.java
#	gson/src/main/java/com/google/gson/JsonParser.java
#	gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java
#	gson/src/main/java/com/google/gson/internal/bind/DateTypeAdapter.java
#	gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java
#	gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java
#	gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java
#	gson/src/main/java/com/google/gson/stream/JsonReader.java
#	gson/src/main/java/com/google/gson/stream/JsonTreeWriter.java
#	gson/src/main/java/com/google/gson/stream/JsonWriter.java
#	gson/src/test/java/com/google/gson/CommentsTest.java
#	gson/src/test/java/com/google/gson/GsonTest.java
#	gson/src/test/java/com/google/gson/MixedStreamTest.java
#	gson/src/test/java/com/google/gson/ToNumberPolicyTest.java
#	gson/src/test/java/com/google/gson/functional/ArrayTest.java
#	gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java
#	gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java
#	gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java
#	gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java
#	gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
#	gson/src/test/java/com/google/gson/functional/ExposeFieldsTest.java
#	gson/src/test/java/com/google/gson/functional/FormattingStyleTest.java
#	gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
#	gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
#	gson/src/test/java/com/google/gson/functional/Java17RecordTest.java
#	gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java
#	gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java
#	gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java
#	gson/src/test/java/com/google/gson/functional/JsonParserTest.java
#	gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java
#	gson/src/test/java/com/google/gson/functional/ObjectTest.java
#	gson/src/test/java/com/google/gson/functional/PrimitiveTest.java
#	gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
#	gson/src/test/java/com/google/gson/functional/StreamingTypeAdaptersTest.java
#	gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java
#	gson/src/test/java/com/google/gson/functional/TypeAdapterPrecedenceTest.java
#	gson/src/test/java/com/google/gson/internal/bind/Java17ReflectiveTypeAdapterFactoryTest.java
#	gson/src/test/java/com/google/gson/internal/bind/JsonTreeReaderTest.java
#	gson/src/test/java/com/google/gson/internal/bind/JsonTreeWriterTest.java
#	gson/src/test/java/com/google/gson/internal/reflect/Java17ReflectionHelperTest.java
#	gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
#	metrics/pom.xml
#	metrics/src/main/java/com/google/gson/metrics/BagOfPrimitives.java
#	metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java
#	metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java
#	metrics/src/main/java/com/google/gson/metrics/NonUploadingCaliperRunner.java
#	metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java
#	metrics/src/main/java/com/google/gson/metrics/SerializationBenchmark.java
#	pom.xml
#	proto/pom.xml
#	proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java
#	proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsTest.java
#	proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithComplexAndRepeatedFieldsTest.java
#	proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithPrimitiveTypesTest.java
#	shrinker-test/pom.xml
#	shrinker-test/src/main/java/com/example/ClassWithExposeAnnotation.java
#	shrinker-test/src/main/java/com/example/ClassWithHasArgsConstructor.java
#	shrinker-test/src/main/java/com/example/ClassWithJsonAdapterAnnotation.java
#	shrinker-test/src/main/java/com/example/ClassWithNoArgsConstructor.java
#	shrinker-test/src/main/java/com/example/ClassWithUnreferencedHasArgsConstructor.java
#	shrinker-test/src/main/java/com/example/ClassWithUnreferencedNoArgsConstructor.java
#	shrinker-test/src/main/java/com/example/ClassWithVersionAnnotations.java
#	shrinker-test/src/main/java/com/example/GenericClasses.java
#	shrinker-test/src/main/java/com/example/Main.java
#	shrinker-test/src/main/java/com/example/NoSerializedNameMain.java
#	shrinker-test/src/main/java/com/example/TestExecutor.java
#	shrinker-test/src/main/java/com/example/UnusedClass.java
#	shrinker-test/src/test/java/com/google/gson/it/ShrinkingIT.java
2024-03-12 13:01:50 +01:00
Marcono1234 ee61e3f020
Add Troubleshooting Guide entry for custom adapter not being used (#2619)
* Add Troubleshooting Guide entry for custom adapter being unused

* Extend documentation

* Fix line endings

* Mention missing adapter in case of "Expected BEGIN_OBJECT ..." exception
2024-03-02 09:58:40 -08:00
Marcono1234 13be1d104d
Fix `GsonBuilder.setDateFormat` ignoring partial DEFAULT; deprecate `setDateFormat(int)` (#2556)
* Fix `GsonBuilder.setDateFormat` ignoring partial DEFAULT; deprecate `setDateFormat(int)`

* Remove date format methods not used by main code

* Adjust example
2024-03-01 12:17:12 -08:00
dependabot[bot] b9b1b810d9
Bump com.github.wvengen:proguard-maven-plugin from 2.6.0 to 2.6.1 (#2637)
Bumps [com.github.wvengen:proguard-maven-plugin](https://github.com/wvengen/proguard-maven-plugin) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/wvengen/proguard-maven-plugin/releases)
- [Changelog](https://github.com/wvengen/proguard-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/wvengen/proguard-maven-plugin/commits/2.6.1)

---
updated-dependencies:
- dependency-name: com.github.wvengen:proguard-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-27 15:56:02 -08:00
dependabot[bot] 0da2c873f7
Bump com.google.errorprone:error_prone_annotations from 2.24.1 to 2.25.0 (#2623)
Bumps [com.google.errorprone:error_prone_annotations](https://github.com/google/error-prone) from 2.24.1 to 2.25.0.
- [Release notes](https://github.com/google/error-prone/releases)
- [Commits](https://github.com/google/error-prone/compare/v2.24.1...v2.25.0)

---
updated-dependencies:
- dependency-name: com.google.errorprone:error_prone_annotations
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:17:17 -08:00
Marcono1234 d148301b44
Fix compilation warnings & add test (#2614) 2024-02-09 16:30:47 -08:00
Maicol db61bb07f0
Adds support to `BigDecimal` in `JsonPrimitive#equals` (#2364)
* Adds support to `BigDecimal`

Adds to the JsonPrimitive#equals the possibility to support BigDecimal

* Adds test

Adds test to check if the equals work with BigDecimals. Code snippet from issue #904

* Implements review comments

Replaces the `.equals` method with the `compareTo` in the `JsonPrimitive#equals`

Change the ternary operator from `||` to `&&` so we are sure that both are `BigDecimal`

Implements tests

* Changes to follow the google-style-guide

* implements review comment

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>

* Fixes the `OperatorPrecedence` warn

* Implements code improvements

- Extracts `thisAsDouble` & `otherAsDouble` variables to avoid double functions calls.

- Adds a comment to improve the code readability.

* Implements `BigDecimal` check in the `JsonPrimitive.equals()`

* Formats the code with `spotless:apply`

---------

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2024-02-09 08:38:42 -08:00
dependabot[bot] 1d3b6b1ece
Bump com.guardsquare:proguard-base from 7.4.1 to 7.4.2 (#2607)
Bumps [com.guardsquare:proguard-base](https://github.com/Guardsquare/proguard) from 7.4.1 to 7.4.2.
- [Release notes](https://github.com/Guardsquare/proguard/releases)
- [Commits](https://github.com/Guardsquare/proguard/compare/v7.4.1...v7.4.2)

---
updated-dependencies:
- dependency-name: com.guardsquare:proguard-base
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-01 07:11:05 -08:00
William 11b2732412
Fix $Gson$Types equals method for TypeVariable when its generic declaration is not a Class (#2599)
* Fix $Gson$Types equals method for TypeVariable when its generic declaration is not a Class

* Test $Gson$Types equals method with TypeVariable when its generic declaration is not a Class

* Add @SuppressWarnings in GsonTypesTest.java
2024-01-30 14:29:07 -08:00
Marcono1234 46ab704221
Support serializing anonymous and local class with custom adapter (#2498)
* Support serializing anonymous and local class with custom adapter

* Fix formatting and fix switched 'expected' and 'actual' in EnumTest

* Minor code improvements

---------

Co-authored-by: Éamonn McManus <emcmanus@google.com>
2024-01-29 08:21:04 -08:00
Marcono1234 5187808233
Enable additional Error Prone checks & fix violations (#2561)
* Enable additional Error Prone checks & fix violations

Some of them also enforce additional Google Java Format requirements which
are not handled by google-java-format, such as disallowing wildcard imports.

Not all experimental checks have been listed because some are not applicable,
such as Dependency Injection framework checks, or checks related to Guava's
immutable collections (since Gson's main code does not have a dependency on
Guava).

Other checks have been omitted because they are probably not relevant
(this was a subjective choice), or would require larger refactoring or
would flag issues with the public API, which cannot be changed easily.

* Address review feedback

---------

Co-authored-by: Éamonn McManus <emcmanus@google.com>
2024-01-09 10:19:09 -08:00
Marcono1234 2bcaaed875
Improve `Calendar` unit tests (#2592) 2024-01-09 09:58:40 -08:00
dependabot[bot] 4781af4fc0
Bump com.google.errorprone:error_prone_annotations from 2.24.0 to 2.24.1 (#2591)
Bumps [com.google.errorprone:error_prone_annotations](https://github.com/google/error-prone) from 2.24.0 to 2.24.1.
- [Release notes](https://github.com/google/error-prone/releases)
- [Commits](https://github.com/google/error-prone/compare/v2.24.0...v2.24.1)

---
updated-dependencies:
- dependency-name: com.google.errorprone:error_prone_annotations
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-04 06:44:50 -08:00
dependabot[bot] 283900806b Bump com.google.errorprone:error_prone_annotations from 2.23.0 to 2.24.0
Bumps [com.google.errorprone:error_prone_annotations](https://github.com/google/error-prone) from 2.23.0 to 2.24.0.
- [Release notes](https://github.com/google/error-prone/releases)
- [Commits](https://github.com/google/error-prone/compare/v2.23.0...v2.24.0)

---
updated-dependencies:
- dependency-name: com.google.errorprone:error_prone_annotations
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-23 15:02:27 +00:00
dependabot[bot] f952ae042c Bump com.google.guava:guava-testlib from 32.1.3-jre to 33.0.0-jre
Bumps [com.google.guava:guava-testlib](https://github.com/google/guava) from 32.1.3-jre to 33.0.0-jre.
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

---
updated-dependencies:
- dependency-name: com.google.guava:guava-testlib
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-19 04:54:13 +00:00
Carpe-Wang 58d1a9f0eb
Fix DateFormat time zone is not restored and add Test. (#2549)
* Fix DateFormat time zone is not restored and add Test.

* delete the test and make sure mvn clean test -X can be SUCCESS

* delete the test and make sure mvn clean test -X can be SUCCESS

* add test

* restore the DateFormat time zone in SqlDateTypeAdapter and SqlTimeTypeAdapter

* Adjust the code according to the code review feedback.

* Adjust the code according to the code review feedback.

* Adjust the code according to the code review feedback.

* Adjust the Test

* fix Werror error

* Adjust the DefaultDateTypeAdapterTest according to the code review feedback.

---------

Co-authored-by: Carpe-Wang <wangcarpe@126.com>
2023-12-05 06:54:53 -08:00
dependabot[bot] 48a534496b
Bump com.guardsquare:proguard-core from 9.1.0 to 9.1.1 (#2560)
Bumps [com.guardsquare:proguard-core](https://github.com/Guardsquare/proguard-core) from 9.1.0 to 9.1.1.
- [Release notes](https://github.com/Guardsquare/proguard-core/releases)
- [Commits](https://github.com/Guardsquare/proguard-core/compare/v9.1.0...v9.1.1)

---
updated-dependencies:
- dependency-name: com.guardsquare:proguard-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-30 12:45:45 -08:00
Éamonn McManus fc748cd0db
Reformat the `GsonBuildConfig.java` template. (#2558)
Otherwise the spotless-maven-plugin checker doesn't like the code
generated from it.
2023-11-28 06:53:35 -08:00
Marcono1234 4197bb6545
Add CI build using JDK 21 (#2552)
* Add CI build using JDK 21

This is mainly to make sure that besides the known JDK 21 build
incompatibilities Gson can be built and run using JDK 21.

* Update ProGuard

* Update Protobuf

3.25.1 is actually newer than 4.0.0-rc-2
2023-11-26 16:36:43 -08:00
Marcono1234 ea4ffde76c
Remove `DateTypeAdapter` to avoid code duplication (#2546)
The same functionality exists in `DefaultDateTypeAdapter` (with some slight
overhead), and there is currently code duplication between these classes.
2023-11-19 14:51:18 -08:00
Marcono1234 08174e2019
Perform minor code clean-up (#2544)
* Perform minor code clean-up

Notable changes:
- Replace most usages of `<code>` with `{@code ...}` in Javadoc
- Add proper summary sentence to `GsonBuilder.enableComplexMapKeySerialization`
- Extend documentation for `GsonBuilder.setDateFormat` methods
- Fix `TypeToken.isAssignableFrom(Type)` throwing AssertionError in some cases
  Maybe the method should not throw an exception in the first place, but it
  might not matter much since it is deprecated already anyway.
- Remove outdated `throws NumberFormatException` from internal
  `JsonReader.nextQuotedValue`; the behavior had been changed by
  85ebaf7c35
- Fix incorrect documentation on JsonScope fields
- Fix unit tests having 'expected' and 'actual' switched
- Use dedicated Truth methods instead of `isTrue()` / `isFalse()`
- Use common helper methods in JsonWriterTest to avoid duplication

* Implement `toString()` for ReflectionAccessFilter constants

* Address most of the review comments

* Add comment about `source.scm.tag=HEAD` warning

Actually it looks like the warning is not actually caused by usage of
`HEAD` as value, but rather because the project has a snapshot version
during development (which is expected though), see
https://github.com/apache/maven-artifact-plugin/blob/maven-artifact-plugin-3.5.0/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java#L140

But this is not a problem either since during release a non-snapshot
version is used.
2023-11-19 09:01:19 -08:00
Marcono1234 6684726476
Validate `GsonBuilder.setDateFormat` style arguments & extend tests (#2545)
`DateFormat` validates these arguments as well, but it is currently not
documented, see https://bugs.openjdk.org/browse/JDK-8319628.

Also moves the other tests for `setDateFormat(String)` from
DefaultTypeAdaptersTest to GsonBuilderTest.
2023-11-18 14:09:25 -08:00
Marcono1234 b7c3e1d0b8
Make Maven build reproducible (#2543)
However, it might still be necessary to use the same OS and JDK version
to actually be able to create identical artifacts.

This commit also formats the `pom.xml` files in the way the Maven Release
Plugin would.
2023-11-18 12:17:40 -08:00
Carpe-Wang 335ff0f9ae
validating the date format, add test case, since NumberFormatExceptio… (#2538)
* validating the date format, add test case, since NumberFormatException extends IllegalArgumentException, it is only necessary to write IllegalArgumentException.

* Apply code formatting with Spotless

---------

Co-authored-by: Carpe-Wang <wangcarpe@126.com>
2023-11-18 10:36:53 -08:00
Marcono1234 c7c645db2f
Formatting follow-up (#2540)
* Formatting follow-up

- Adds formatting commits to .git-blame-ignore-revs so that they don't
  distract during Git blame
- Restores hard line breaks in Troubleshooting.md using `\` instead of
  trailing spaces
- Changes formatting of some string literals and comments
- Fixes accidental Javadoc and comment issues introduced by manual changes
  of formatting commit
- Fixes license header in $Gson$Types.java erroneously being a Javadoc
  comment and being reformatted
- Slightly changes `JsonReader` `getPath` and `getPreviousPath` documentation
  to help Javadoc detect first sentence as summary

* Remove `spotless:off` markers

* Add empty line before comment

* Check format for .github YAML files
2023-11-14 15:09:54 -08:00
Maicol c2a0e4634a
Updates the line separator from `CRLF` to `LF` (#2536) 2023-11-10 12:36:42 -08:00
Maicol 2c94c757a6
Formats codebase (#2531)
* Formats `.java` files

* Formats `.md` files
2023-11-06 11:59:01 -08:00
dependabot[bot] cb6643f148
Bump org.codehaus.mojo:templating-maven-plugin from 1.0.0 to 3.0.0 (#2527)
Bumps [org.codehaus.mojo:templating-maven-plugin](https://github.com/mojohaus/templating-maven-plugin) from 1.0.0 to 3.0.0.
- [Release notes](https://github.com/mojohaus/templating-maven-plugin/releases)
- [Commits](https://github.com/mojohaus/templating-maven-plugin/compare/templating-maven-plugin-1.0.0...3.0.0)

---
updated-dependencies:
- dependency-name: org.codehaus.mojo:templating-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Éamonn McManus <emcmanus@google.com>
2023-11-06 09:18:59 -08:00
dependabot[bot] d9efc1596d
Bump org.moditect:moditect-maven-plugin from 1.0.0.Final to 1.1.0 (#2526)
Bumps [org.moditect:moditect-maven-plugin](https://github.com/moditect/moditect) from 1.0.0.Final to 1.1.0.
- [Release notes](https://github.com/moditect/moditect/releases)
- [Commits](https://github.com/moditect/moditect/compare/1.0.0.Final...1.1.0)

---
updated-dependencies:
- dependency-name: org.moditect:moditect-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 07:32:43 -08:00
Marcono1234 6a9d240f78
Add limits when deserializing `BigDecimal` and `BigInteger` (#2510)
* Add limits when deserializing `BigDecimal` and `BigInteger`

* Use assertThrows

* Don't check number limits in JsonReader
2023-10-23 13:51:29 -07:00
dependabot[bot] e915b2e44c
Bump com.google.errorprone:error_prone_annotations from 2.22.0 to 2.23.0 (#2514)
Bumps [com.google.errorprone:error_prone_annotations](https://github.com/google/error-prone) from 2.22.0 to 2.23.0.
- [Release notes](https://github.com/google/error-prone/releases)
- [Commits](https://github.com/google/error-prone/compare/v2.22.0...v2.23.0)

---
updated-dependencies:
- dependency-name: com.google.errorprone:error_prone_annotations
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-19 17:46:25 -07:00
dependabot[bot] 6f79800d26
Bump com.google.guava:guava-testlib from 32.1.2-jre to 32.1.3-jre (#2509)
Bumps [com.google.guava:guava-testlib](https://github.com/google/guava) from 32.1.2-jre to 32.1.3-jre.
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

---
updated-dependencies:
- dependency-name: com.google.guava:guava-testlib
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-11 07:30:27 -07:00
Marcono1234 df01e943e5
Improve formatting (#2505)
* Improve formatting

* Move `&&` to start of line
2023-10-03 09:56:07 -07:00
SP 0109f45129
issue#2436: Throw exception when registering adapter for Object or JsonElement (#2479)
* Code changes and tests for #2436 to throw exception when trying to register adapter for Object or JsonElement

* #2436 - Updates to User guide & comments to indicate exception cases and fix for 7 test cases of Parameterized Type

* #2436 - Fixes as per the review comments.

* #2436 - Refactored as per latest review comments + throwing error message.

* #2436 - added a clarifying comment in a positive test case.

* #2436 - formatting and minor changes as per review.

* Update gson/src/main/java/com/google/gson/GsonBuilder.java

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>

* Update gson/src/test/java/com/google/gson/GsonBuilderTest.java

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>

* Update gson/src/test/java/com/google/gson/GsonBuilderTest.java

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>

---------

Co-authored-by: Sachin Patil <sachin.patil2@capitalone.com>
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2023-10-03 07:29:54 -07:00
Marcono1234 e7cf5c4583
Only create one `BoundField` instance per field in `ReflectiveTypeAdapterFactory` (#2440)
* Only create one BoundField instance per field in ReflectiveTypeAdapterFactory

Instead of creating a BoundField for every possible name of a field (for
SerializedName usage) and then storing for that BoundField whether it is
serialized or deserialized, instead only create one BoundField and then have
a separate Map<String, BoundField> for deserialized fields, and a separate
List<BoundField> for serialized fields.

* Fix indentation
2023-09-30 13:23:31 -07:00
Éamonn McManus 45acc4db42
Suppress serialization warnings. (#2502)
Recent versions of javac emit a warning if a serializable class has
a non-transient instance field with a declared type that does not
inherit `Serializable`. In this context, we know that the actual
values will always be serializable.
2023-09-30 12:41:04 -07:00
Marcono1234 ff401f1545
Remove obsolete Error Prone warning suppressions (#2497)
The latest Error Prone version fixed a bug which makes these
suppressions obsolete.
2023-09-23 08:33:09 -07:00
dependabot[bot] 8756189a14
Bump com.google.errorprone:error_prone_annotations from 2.21.1 to 2.22.0 (#2493)
Bumps [com.google.errorprone:error_prone_annotations](https://github.com/google/error-prone) from 2.21.1 to 2.22.0.
- [Release notes](https://github.com/google/error-prone/releases)
- [Commits](https://github.com/google/error-prone/compare/v2.21.1...v2.22.0)

---
updated-dependencies:
- dependency-name: com.google.errorprone:error_prone_annotations
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-22 17:50:33 -07:00
Éamonn McManus edfaf0c387
Add clarifying parentheses to a ternary expression. (#2496)
The latest Error Prone version issues a warning without the parentheses.
Since we build with `-Werror`, that breaks the build.
2023-09-22 17:43:14 -07:00
Marcono1234 e93fda9f17
Fix typos and improve Gson Design Document formatting (#2491)
* Fix typos and grammar issues

Most of them were found by IntelliJ

* Improve formatting and fix typos in Gson Design Document
2023-09-20 15:44:15 -07:00
Johannes Frohnmeyer 7d030fad60
Fix build
ci/woodpecker/push/woodpecker Pipeline was successful Details
2023-09-19 20:14:48 +02:00
Johannes Frohnmeyer c46cbf85d4
Merge upstream 2023-09-19 17:22:29 +02:00
Johannes Frohnmeyer db89f98ed8
Add "configure" methods to Gson to apply JsonWriter/JsonReader configs 2023-09-19 16:29:07 +02:00
Marcono1234 70bda4b9c9
Throw exception when calling `JsonWriter.name` outside JSON object (#2476)
Previous fix in 392cc65ff3 only covered writing
name as top level value, but not when trying to write name inside JSON array.

Removed `stackSize == 0` check from `JsonWriter.name` because that is done
already by `peek()` call.
2023-08-29 08:41:06 -07:00
Marcono1234 88fd6d1390
Improve `JsonAdapter` documentation and tests (#2442)
* Document how `JsonAdapter` creates adapter instances & add tests

* Extend `JsonAdapter.nullSafe()` documentation

* Improve test for JsonAdapter factory returning null

Existing test `JsonAdapterNullSafeTest` had misleading comments; while it
did in the end detect if null had not been handled correctly, that only
worked because the field `JsonAdapterFactory.recursiveCall` is static and
one test method therefore affected the state of the other test method.
If the test methods were run separately in different test runs, they would
not have detected if null was handled correctly, because the factory would
not have returned null.

* Extend JsonAdapter nullSafe test

* Extend test
2023-08-23 07:09:32 -07:00
Marcono1234 7ee5ad6cd1
Fix `Gson.getDelegateAdapter` not working properly for `JsonAdapter` (#2435)
* Fix `Gson.getDelegateAdapter` not working properly for `JsonAdapter`

* Address review feedback and add comments regarding thread-safety

* Revert InstanceCreator instance validation

* Disallow `null` as `skipPast`

* Avoid `equals` usage in `getDelegateAdapter` & minor other changes

Previously `getDelegateAdapter` called `factories.contains(skipPast)`,
but unlike the other comparisons which check for reference equality,
that would have used the `equals` method.
This could lead to spurious "GSON cannot serialize ..." exceptions
if two factory instances compared equal, but the one provided as
`skipPast` had not been registered yet.
2023-08-22 17:15:18 -07:00
shivam-sehgal 392cc65ff3
Changes to ensure if no object is opened user won't be able to write property name (#2475)
* Changes to ensure if no object is opened user won't be able to add prop in the object

* review points

* spelling correction
2023-08-22 10:12:31 -07:00
Søren Gjesse 7b5629bcfc
Update ProGuard default shrinking rules (#2448)
* Update ProGuard default shrinking rules to correctly deal with classes without a no-args constructor

* Update test after changing default shrinking rules

* Adjust shrinker tests

* Update rules

* Addressed review comments

* Addressed more review comments

* Addressed more review comments

---------

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2023-08-22 08:40:31 -07:00
Marcono1234 7b8ce2b9f7
Prevent `TypeToken` from capturing type variables (#2376)
* Prevent `TypeToken` from capturing type variables

* Use hyphen for term "type-safe"

Not completely sure if that is grammatically correct, but it might make the
text a bit easier to understand.

* Update Troubleshooting Guide URLs in tests from 'master' to 'main'

* Rename system property

* Simplify system property check
2023-08-14 14:26:05 -07:00