File tree Expand file tree Collapse file tree 2 files changed +32
-10
lines changed
google-cloud-logging/src/main/java/com/google/cloud/logging Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Original file line number Diff line number Diff line change 3434import com .google .logging .v2 .LogEntrySourceLocation ;
3535import com .google .logging .v2 .LogName ;
3636import java .io .Serializable ;
37- import java .time .Duration ;
3837import java .time .Instant ;
3938import java .util .HashMap ;
4039import java .util .Map ;
@@ -613,14 +612,6 @@ public JsonElement serialize(
613612 }
614613 }
615614
616- static final class DurationSerializer implements JsonSerializer <Duration > {
617- @ Override
618- public JsonElement serialize (
619- Duration src , java .lang .reflect .Type typeOfSrc , JsonSerializationContext context ) {
620- return new JsonPrimitive (src .toString ());
621- }
622- }
623-
624615 static final class SourceLocationSerializer implements JsonSerializer <SourceLocation > {
625616 @ Override
626617 public JsonElement serialize (
@@ -658,7 +649,6 @@ public StructuredLogFormatter(StringBuilder builder) {
658649 checkNotNull (builder );
659650 this .gson =
660651 new GsonBuilder ()
661- .registerTypeAdapter (Duration .class , new DurationSerializer ())
662652 .registerTypeAdapter (Instant .class , new InstantSerializer ())
663653 .registerTypeAdapter (SourceLocation .class , new SourceLocationSerializer ())
664654 .registerTypeAdapter (HttpRequest .RequestMethod .class , new RequestMethodSerializer ())
Original file line number Diff line number Diff line change 197197 <ignoredUnusedDeclaredDependencies >org.objenesis:objenesis</ignoredUnusedDeclaredDependencies >
198198 </configuration >
199199 </plugin >
200+ <plugin >
201+ <groupId >org.apache.maven.plugins</groupId >
202+ <artifactId >maven-jar-plugin</artifactId >
203+ <executions >
204+ <execution >
205+ <id >default-jar</id >
206+ <phase >package</phase >
207+ <goals >
208+ <goal >jar</goal >
209+ </goals >
210+ <configuration >
211+ <archive >
212+ <manifestEntries >
213+ <!-- This manifest entry is ignored by java 8.
214+ It allows inter-module access when Gson serializes
215+ the private variables of java.time.Duration -->
216+ <Add-Opens >java.base/java.time=ALL-UNNAMED</Add-Opens >
217+ </manifestEntries >
218+ </archive >
219+ </configuration >
220+ </execution >
221+ </executions >
222+ </plugin >
223+ <plugin >
224+ <groupId >org.apache.maven.plugins</groupId >
225+ <artifactId >maven-surefire-plugin</artifactId >
226+ <configuration >
227+ <!-- This arg line allows inter-module access when Gson serializes
228+ the private variables of java.time.Duration -->
229+ <argLine >--add-opens java.base/java.time=ALL-UNNAMED</argLine >
230+ </configuration >
231+ </plugin >
200232 </plugins >
201233 </pluginManagement >
202234 </build >
You can’t perform that action at this time.
0 commit comments