Skip to content

Commit

Permalink
Fix warnings (google#2014)
Browse files Browse the repository at this point in the history
* Fix warnings

* Address review feedback
  • Loading branch information
Marcono1234 authored and tibor-universe committed Nov 17, 2021
1 parent 22b5f20 commit 36bad3e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
1 change: 0 additions & 1 deletion gson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<includePackageNames>com.google.gson</includePackageNames>
<excludePackageNames>com.google.gson.internal:com.google.gson.internal.bind</excludePackageNames>
<links>
<link>https://docs.oracle.com/javase/6/docs/api/</link>
Expand Down
5 changes: 4 additions & 1 deletion gson/src/main/java/com/google/gson/JsonArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ public byte getAsByte() {
@Override
public char getAsCharacter() {
if (elements.size() == 1) {
return elements.get(0).getAsCharacter();
JsonElement element = elements.get(0);
@SuppressWarnings("deprecation")
char result = element.getAsCharacter();
return result;
}
throw new IllegalStateException();
}
Expand Down
5 changes: 4 additions & 1 deletion gson/src/test/java/com/google/gson/JsonObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public void testAddingCharacterProperties() throws Exception {
JsonElement jsonElement = jsonObj.get(propertyName);
assertNotNull(jsonElement);
assertEquals(String.valueOf(value), jsonElement.getAsString());
assertEquals(value, jsonElement.getAsCharacter());

@SuppressWarnings("deprecation")
char character = jsonElement.getAsCharacter();
assertEquals(value, character);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import org.junit.Test;

import com.google.gson.internal.JavaVersion;

/**
* Unit and functional tests for {@link JavaVersion}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.JavaVersion;
import com.google.gson.internal.bind.DefaultDateTypeAdapter;
import com.google.gson.internal.bind.DefaultDateTypeAdapter.DateType;
import com.google.gson.reflect.TypeToken;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package com.google.gson.internal.bind.util;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import org.junit.function.ThrowingRunnable;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.*;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

public class ISO8601UtilsTest {

@Rule
public final ExpectedException exception = ExpectedException.none();

private static TimeZone utcTimeZone() {
return TimeZone.getTimeZone("UTC");
}
Expand Down Expand Up @@ -87,8 +83,12 @@ public void testDateParseSpecialTimezone() throws ParseException {

@Test
public void testDateParseInvalidTime() throws ParseException {
String dateStr = "2018-06-25T61:60:62-03:00";
exception.expect(ParseException.class);
ISO8601Utils.parse(dateStr, new ParsePosition(0));
final String dateStr = "2018-06-25T61:60:62-03:00";
assertThrows(ParseException.class, new ThrowingRunnable() {
@Override
public void run() throws Throwable {
ISO8601Utils.parse(dateStr, new ParsePosition(0));
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static List<Object[]> parameters() {
assertEquals("$", reader.getPath());
}

enum Factory {
public enum Factory {
STRING_READER {
@Override public JsonReader create(String data) {
return new JsonReader(new StringReader(data));
Expand Down

0 comments on commit 36bad3e

Please sign in to comment.