Commit Graph

19 Commits

Author SHA1 Message Date
Johannes Frohnmeyer b6cc63919d
Merge remote-tracking branch 'origin/master'
ci/woodpecker/push/woodpecker Pipeline failed Details
# Conflicts:
#	.github/ISSUE_TEMPLATE/bug_report.md
#	.github/workflows/build.yml
#	extras/pom.xml
#	extras/src/main/java/com/google/gson/graph/GraphAdapterBuilder.java
#	extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.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
#	gson/src/test/java/com/google/gson/CommentsTest.java
#	gson/src/test/java/com/google/gson/ToNumberPolicyTest.java
#	gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
#	gson/src/test/java/com/google/gson/functional/JsonParserTest.java
#	gson/src/test/java/com/google/gson/functional/LeniencyTest.java
#	gson/src/test/java/com/google/gson/functional/MapTest.java
#	gson/src/test/java/com/google/gson/functional/PrimitiveCharacterTest.java
#	gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
#	gson/src/test/java/com/google/gson/functional/SecurityTest.java
#	gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
#	gson/src/test/resources/testcases-proguard.conf
#	metrics/pom.xml
#	metrics/src/main/java/com/google/gson/metrics/BagOfPrimitives.java
#	proto/pom.xml
#	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
2023-01-21 14:24:25 +01:00
Maicol be87c3fd0e
Port Junit test to Truth in the package `com.google.gson` of the module `gson` (#2299)
* Add the Truth dependency

* Port Junit test to Truth in the package `com.google.gson` of the module `gson`

* Replace the `assertThat(e.getMessage()).isEqualTo(...)"` with `assertThat(e).hasMessageThat().isEqualTo(...)`

* Minor fixes
2023-01-17 07:59:10 -08:00
Marcono1234 e4c3b653a6
Fix non-threadsafe creation of adapter for type with cyclic dependency (#1832)
* Fix non-threadsafe creation of adapter for type with cyclic dependency

* Improve handling of broken adapters during Gson.getAdapter(...) call

* Improve test

* Slightly improve implementation and extend tests

* Simplify getAdapter implementation

* Convert GsonTest to JUnit 4 test

* Clarify getAdapter concurrency behavior
2022-12-05 09:10:36 -08:00
Johannes Frohnmeyer ce02cb3bc1
Merge remote-tracking branch 'origin/master'
# Conflicts:
#	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/internal/bind/ArrayTypeAdapter.java
#	gson/src/main/java/com/google/gson/stream/JsonWriter.java
#	gson/src/test/java/com/google/gson/functional/ArrayTest.java
#	gson/src/test/java/com/google/gson/functional/MapTest.java
#	pom.xml
2022-09-14 19:20:24 +02:00
Marcono1234 5bebf970d1
Fix changes to GsonBuilder affecting existing Gson instances (#1815)
Previously when a GsonBuilder had created a Gson instance and was afterwards
reused and different type adapters were added, new GsonBuilder instances
obtained from the previous Gson instance through Gson.newBuilder() would have
been affected by the GsonBuilder changes.

This commit fixes this and additionally adds some more unit tests.
2022-08-22 06:49:48 -07:00
Marcono1234 18b9ba407d
Improve GsonTest.testGetAdapter_Concurrency (#2177)
Makes the test implementation more reliable to prevent flaws in the test
setup causing spurious test success.
2022-08-19 10:25:20 -07:00
Marcono1234 4552db2630
Prefer existing adapter for concurrent `Gson.getAdapter` calls (#2153)
Additionally fail fast for null as type (previous null support was broken
and would have thrown NullPointerException further below anyways).
2022-08-01 10:59:04 -07:00
Johannes Frohnmeyer dc4e61ac7b
Several breaking changes 2022-05-17 21:20:10 +02:00
Johannes Frohnmeyer 9d7fd891ee
Merge branch 'allow_duplicate_map_key'
# Conflicts:
#	gson/src/main/java/com/google/gson/GsonBuilder.java
#	gson/src/test/java/com/google/gson/GsonTest.java
2022-05-12 22:54:17 +02:00
Marcono1234 e82637c485
Add support for reflection access filter (#1905)
* Add support for reflection access filter

* Improve documentation

* Fix compilation errors

* Relax handling for BLOCK_ALL when invoking default constructor

* Improve handling for inherited fields

* Fix accessible test failing for static fields

* Simplify ReflectiveTypeAdapterFactory field writing

* Fix GsonBuilder changes affecting created Gson instances

* Improve documentation

* Improve handling for IllegalAccessException

For Java < 9, AccessibleObject.canAccess is not available and therefore checks
might pass even if object is not accessible, causing IllegalAccessException
later.

* Fix incorrect GsonBuilder.addReflectionAccessFilter documentation
2022-04-17 09:05:18 -07:00
Marcono1234 615c8835d3
Add `GsonBuilder.disableJdkUnsafe()` (#1904)
* Add GsonBuilder.disableJdkUnsafe()

* Address review feedback
2021-12-30 15:08:18 -08:00
Marcono1234 deaa3a6cd9
Fix `Gson.newJsonWriter` ignoring lenient and HTML-safe setting (#1989)
* Improve Gson newJsonWriter and newJsonReader documentation

* Consider lenient and HTML-safe setting for Gson.newJsonWriter

* Remove empty line between imports
2021-11-01 15:11:10 -07:00
Marcono1234 c54caf308c
Deprecate `Gson.excluder()` exposing internal `Excluder` class (#1986) 2021-10-25 11:28:16 -07:00
Lyubomyr Shaydariv fe30b85224
Support arbitrary Number implementation for Object and Number deserialization (#1290)
* Object and Number type adapters number deserialization can be configured

* Change wording of ToNumberStrategy documentation

* Use inline links in doc sparingly

If the element has already been linked before, don't create a link for
every subsequent occurrence.

See also (slightly dated)
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html#inlinelinks

* Link to default to-number policies in ToNumberStrategy doc

* Reduce code duplication for deserializing Number

* Hide default factory constants of NumberTypeAdapter and ObjectTypeAdapter

This encapsulates the logic a little bit better.
Additionally refactored factory created by NumberTypeAdapter to only create
TypeAdapter once and then have factory reuse that adapter for better
performance.

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-10-08 17:09:43 -07:00
tiegen e6b7da988a
Update gson/src/test/java/com/google/gson/GsonTest.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-25 16:34:26 +08:00
tiegen 8990169194
Update gson/src/test/java/com/google/gson/GsonTest.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-04-25 16:34:18 +08:00
saddays a0ea108c59 allow deserialize duplicate map key 2021-04-21 14:39:45 +08:00
Warren Smith 08bbb226f1 Add newBuilder() API (#1142)
* Add Gson.newBuilder API.

* Remove redundant test.

* Address Codacy comments.

* Reduce visibility of GsonBuilder constructor.
2017-09-20 18:53:10 -07:00
Ryan Harter a851569ab9 Adds getters for config fields.
This adds simple getters for certain config fields that would be helpful in custom
TypeAdapters to deal with situations like this:
https://github.com/rharter/auto-value-gson/issues/18
2016-04-26 15:30:01 -04:00