File tree 2 files changed +32
-10
lines changed
google-cloud-logging/src/main/java/com/google/cloud/logging 2 files changed +32
-10
lines changed Original file line number Diff line number Diff line change 34
34
import com .google .logging .v2 .LogEntrySourceLocation ;
35
35
import com .google .logging .v2 .LogName ;
36
36
import java .io .Serializable ;
37
- import java .time .Duration ;
38
37
import java .time .Instant ;
39
38
import java .util .HashMap ;
40
39
import java .util .Map ;
@@ -613,14 +612,6 @@ public JsonElement serialize(
613
612
}
614
613
}
615
614
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
-
624
615
static final class SourceLocationSerializer implements JsonSerializer <SourceLocation > {
625
616
@ Override
626
617
public JsonElement serialize (
@@ -658,7 +649,6 @@ public StructuredLogFormatter(StringBuilder builder) {
658
649
checkNotNull (builder );
659
650
this .gson =
660
651
new GsonBuilder ()
661
- .registerTypeAdapter (Duration .class , new DurationSerializer ())
662
652
.registerTypeAdapter (Instant .class , new InstantSerializer ())
663
653
.registerTypeAdapter (SourceLocation .class , new SourceLocationSerializer ())
664
654
.registerTypeAdapter (HttpRequest .RequestMethod .class , new RequestMethodSerializer ())
Original file line number Diff line number Diff line change 197
197
<ignoredUnusedDeclaredDependencies >org.objenesis:objenesis</ignoredUnusedDeclaredDependencies >
198
198
</configuration >
199
199
</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 >
200
232
</plugins >
201
233
</pluginManagement >
202
234
</build >
You can’t perform that action at this time.
0 commit comments