Commit Graph

1752 Commits

Author SHA1 Message Date
Éamonn McManus
6e06bf0d89 Fix for an ArrayIndexOutOfBoundsException.
The `fillBuffer` method changes `pos`, so it is incorrect to cache
its previous value.
2021-11-11 14:12:44 -05:00
Marcono1234
b0595c595b
Fix failing to serialize Collection or Map with inaccessible constructor (#1902)
* Remove UnsafeReflectionAccessor

Revert #1218

Usage of sun.misc.Unsafe to change internal AccessibleObject.override field
to suppress JPMS warnings goes against the intentions of the JPMS and does not
work anymore in newer versions, see #1540.
Therefore remove it and instead create a descriptive exception when making a
member accessible fails. If necessary users can also still use `java` command
line flags to open external modules.

* Fix failing to serialize Collection or Map with inaccessible constructor

Also remove tests which rely on Java implementation details.

* Don't keep reference to access exception of ConstructorConstructor

This also avoids a confusing stack trace, since the previously caught
exception might have had a complete unrelated stack trace.

* Remove Maven toolchain requirement

* Address review feedback

* Add back test for Security Manager
2021-11-09 07:16:35 -08:00
dependabot[bot]
0d9f6b677a
Bump guava from 30.1.1-jre to 31.0.1-jre (#2016)
Bumps [guava](https://github.com/google/guava) from 30.1.1-jre to 31.0.1-jre.
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

---
updated-dependencies:
- dependency-name: com.google.guava:guava
  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>
2021-11-08 08:43:47 -08:00
Marcono1234
ca2ed748ba
Fix warnings (#2014)
* Fix warnings

* Address review feedback
2021-11-07 08:43:49 -08:00
Marcono1234
cc505e1b9f
Convert codegen, metrics and proto to Maven submodules (#2008)
* Convert codegen, metrics and proto to Maven submodules

* Fix import order
2021-11-07 08:42:08 -08:00
Marcono1234
a92bbf849c
Improve TreeTypeAdapter thread-safety (#1976)
* Improve TreeTypeAdapter thread-safety

Gson claims to be thread-safe so TreeTypeAdapter.delegate() might be
called by multiple threads. To guarantee that each thread sees a fully
constructed `delegate`, the field has to be `volatile`.

* Improve TreeTypeAdapter thread race comment
2021-11-01 15:13:08 -07: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
e0de45ff69
Delete unused LinkedHashTreeMap (#1992)
Class seems to be unused since commit f29d5bc37b.
Gson currently only uses LinkedTreeMap.
2021-11-01 15:09:14 -07:00
Marcono1234
b4dab86b10
Make default adapters stricter; improve exception messages (#2000)
* Make default adapters stricter; improve exception messages

* Reduce scope of synchronized blocks

* Improve JsonReader.getPath / getPreviousPath Javadoc
2021-11-01 15:08:04 -07:00
Marcono1234
b3188c1132
Fix FieldNamingPolicy.upperCaseFirstLetter uppercasing non-letter (#2004) 2021-11-01 15:05:04 -07:00
Éamonn McManus
466ca72916 Update version number in UserGuide.md and proto/pom.xml. 2021-10-31 06:57:33 -07:00
Marcono1234
121bcede96
Update project version in README (#2006) 2021-10-31 06:52:51 -07:00
Éamonn McManus
031db9d473
Update CHANGELOG.md for 2.8.9. (#2005)
* Update CHANGELOG.md for 2.8.9.

* Adjust snapshot version. Gson versions have three numbers.
2021-10-29 13:41:12 -07:00
Éamonn McManus
128586847b [maven-release-plugin] prepare for next development iteration 2021-10-29 12:58:56 -07:00
Éamonn McManus
6a368d89da [maven-release-plugin] prepare release gson-parent-2.8.9 2021-10-29 12:58:54 -07:00
Marcono1234
ba96d53bad
Fix missing bounds checks for JsonTreeReader.getPath() (#2001)
There are situations where the stack of JsonTreeReader contains a JsonArray
or JsonObject without a subsequent Iterator, for example after calling peek()
or nextName().
When JsonTreeReader.getPath() is called afterwards it therefore must not
assume that a JsonArray or JsonObject is always followed by an Iterator.

The only reason why this never caused an ArrayIndexOutOfBoundsException in
the past is because the stack has an even default size (32) so it would just
have read the next `null`.
However, if the stack had for example the default size 31, a user created a
JsonTreeReader for 16 JSON arrays nested inside each other, then called 15
times beginArray(), followed by peek() and getPath() the exception would
occur.
2021-10-25 12:14:41 -07:00
Jaroslav Tulach
ca1df7f7e0
#1981: Optional OSGi bundle's dependency on sun.misc package (#1993)
* #1981: Avoid OSGi bundle's dependency on sun.misc package

* Specify optional dependency on sun.misc.Unsafe

* Adjusting the test to sun.misc import being optional

* Using Collections.list and for loop

* Let the fail message include name of package

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

* Closing the input stream

* Dedicated assertSubstring method

Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2021-10-25 11:32:10 -07:00
Marcono1234
c54caf308c
Deprecate Gson.excluder() exposing internal Excluder class (#1986) 2021-10-25 11:28:16 -07:00
Marcono1234
e6fae590cf
Prevent Java deserialization of internal classes (#1991)
Adversaries might be able to forge data which can be abused for DoS attacks.
These classes are already writing a replacement JDK object during serialization
for a long time, so this change should not cause any issues.
2021-10-13 10:14:57 -07:00
Marcono1234
bda2e3d16a
Improve number strategy implementation (#1987)
* Fix GsonBuilder not copying number strategies from Gson

* Improve ToNumberPolicy exception messages
2021-10-11 16:14:47 -07:00
Marcono1234
cd748df712
Fix LongSerializationPolicy null handling being inconsistent with Gson (#1990)
Gson does not actually use the specified LongSerializationPolicy but instead
uses type adapters which emulate the behavior. However, previously Gson's
implementation did not match LongSerializationPolicy regarding null handling.

Because it is rather unlikely that LongSerializationPolicy has been used on
its own, this commit adjusts its implementation to match Gson's behavior
(instead of the other way around).
2021-10-11 12:34:32 -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
Marcono1234
1cc1627423
Fix incorrect feature request template label (#1982) 2021-10-07 10:41:44 -07:00
dependabot[bot]
7b9a283a7a
Bump bnd-maven-plugin from 5.3.0 to 6.0.0 (#1985)
Bumps [bnd-maven-plugin](https://github.com/bndtools/bnd) from 5.3.0 to 6.0.0.
- [Release notes](https://github.com/bndtools/bnd/releases)
- [Changelog](https://github.com/bndtools/bnd/blob/master/docs/ADDING_RELEASE_DOCS.md)
- [Commits](https://github.com/bndtools/bnd/commits/6.0.0)

---
updated-dependencies:
- dependency-name: biz.aQute.bnd:bnd-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>
2021-10-06 17:58:02 -07:00
Marcono1234
7cfdf44893
Add GitHub issue templates (#1977)
* Add GitHub issue templates

* Adjust bug report issue template
2021-09-28 16:35:55 -07:00
dependabot[bot]
b0f3237bb8
Bump proguard-maven-plugin from 2.4.0 to 2.5.1 (#1980)
Bumps [proguard-maven-plugin](https://github.com/wvengen/proguard-maven-plugin) from 2.4.0 to 2.5.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)

---
updated-dependencies:
- dependency-name: com.github.wvengen:proguard-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>
2021-09-28 09:59:56 -07:00
Marcono1234
3b7835a18b
Switch to GitHub Actions (#1974) 2021-09-24 08:34:16 -07:00
Marcono1234
aa5554e69a
Don't exclude static local classes (#1969) 2021-09-17 18:12:47 -07:00
dependabot[bot]
6a5e775362
Bump maven-scm-provider-gitexe from 1.11.3 to 1.12.0 (#1967)
Bumps maven-scm-provider-gitexe from 1.11.3 to 1.12.0.

---
updated-dependencies:
- dependency-name: org.apache.maven.scm:maven-scm-provider-gitexe
  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>
2021-09-17 17:27:30 -07:00
Marcono1234
26a1928277
Fix RuntimeTypeAdapterFactory depending on internal Streams class (#1959)
* Fix RuntimeTypeAdapterFactory depending on internal Streams class

* Clean up gson-extras project, make it Maven module of gson-parent

* Remove broken test from GraphAdapterBuilderTest
2021-09-17 17:21:37 -07:00
Marcono1234
f1f90313fc
Improve Maven build (#1964)
- Specify missing plugin versions
- Fix or suppress ProGuard notes and warnings
2021-09-17 17:19:50 -07:00
dependabot[bot]
b82c76717b
Bump maven-javadoc-plugin from 3.3.0 to 3.3.1 (#1956)
Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.3.0 to 3.3.1.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.3.0...maven-javadoc-plugin-3.3.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-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>
2021-09-08 06:14:06 -07:00
Z
ebe4b581dd
update RawCollectionsExample.java (#1953)
use static method instead deprecated method
2021-09-07 08:02:04 -07:00
Z
9484297fbb
update UserGuide.md (#1954)
Id Class does not have get method, we should new a instance.
2021-09-07 08:00:11 -07:00
Nikita Novik
4f2aeaa288
Add license note to GSON POM file. (#1951)
* Add license note to GSON POM file.
2021-09-06 10:35:43 -07:00
Éamonn McManus
4bb67483f9
Update dependencies in proto/pom.xml. (#1949)
Also use GeneratedMessageV3 rather than GeneratedMessage, consistent with recent versions of protoc.
2021-09-01 17:11:48 -07:00
Éamonn McManus
c8f26dc907
Add missing calls when testing for exceptions. (#1948) 2021-08-31 15:03:45 -07:00
Éamonn McManus
1a2e58a42f
Remove an unused import. (#1947) 2021-08-31 14:55:07 -07:00
Simon Guerout
66fd2acdcf Fix formatting 2021-08-30 09:57:08 -07:00
Simon Guerout
ac14b4c197 Make the nextJsonElement more robust
Add test cases
2021-08-30 09:57:08 -07:00
Simon Guerout
62a9702385 Improve the speed of the JSON_ELEMENT TypeAdapter when the object graph has already been turned into a JsonElement 2021-08-30 09:57:08 -07:00
Éamonn McManus
1023f0fe34
Merge pull request #1707 from Marcono1234/optional-sql
Make dependency on java.sql optional
2021-08-25 11:26:58 -07:00
Éamonn McManus
69173b02ea
Merge branch 'master' into optional-sql 2021-08-24 13:41:12 -07:00
Éamonn McManus
03be835914 Update change log, and version numbers in documentation. 2021-08-20 10:02:13 -07:00
Éamonn McManus
b2f661166f [maven-release-plugin] prepare for next development iteration 2021-08-20 09:07:21 -07:00
Éamonn McManus
b41030d3dc [maven-release-plugin] prepare release gson-parent-2.8.8 2021-08-20 09:07:19 -07:00
Éamonn McManus
81f25c8b45
Merge pull request #1936 from google/dependabot/maven/org.apache.maven.scm-maven-scm-provider-gitexe-1.11.3
Bump maven-scm-provider-gitexe from 1.11.2 to 1.11.3
2021-08-12 11:47:47 -07:00
Éamonn McManus
a7404e8ede
Merge pull request #1935 from google/dependabot/maven/org.apache.maven.scm-maven-scm-api-1.11.3
Bump maven-scm-api from 1.11.2 to 1.11.3
2021-08-12 11:47:28 -07:00
dependabot[bot]
205df01c04
Bump maven-scm-provider-gitexe from 1.11.2 to 1.11.3
Bumps maven-scm-provider-gitexe from 1.11.2 to 1.11.3.

---
updated-dependencies:
- dependency-name: org.apache.maven.scm:maven-scm-provider-gitexe
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 03:04:06 +00:00
dependabot[bot]
f98dabd1e9
Bump maven-scm-api from 1.11.2 to 1.11.3
Bumps [maven-scm-api](https://github.com/apache/maven-scm) from 1.11.2 to 1.11.3.
- [Release notes](https://github.com/apache/maven-scm/releases)
- [Commits](https://github.com/apache/maven-scm/compare/maven-scm-1.11.2...maven-scm-1.11.3)

---
updated-dependencies:
- dependency-name: org.apache.maven.scm:maven-scm-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 03:04:02 +00:00