aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar brandjon <brandjon@google.com>2017-08-16 22:46:02 +0200
committerGravatar Irina Iancu <elenairina@google.com>2017-08-17 09:54:22 +0200
commitf107a53c916d4f6f1fab0fa011ebf9c1d920b1c7 (patch)
tree7936e53f003a2b6f25b681f6fcd5e19b30ef283b /src/main/java/com/google/devtools
parent24ed1ef4c3ad64ec63e46fdde3122d66e6d9a07f (diff)
Fix NPE in Printer
RELNOTES: None PiperOrigin-RevId: 165489091
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/Printer.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Printer.java b/src/main/java/com/google/devtools/build/lib/syntax/Printer.java
index b91237ad72..1c902a6c2d 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Printer.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Printer.java
@@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.lib.syntax;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.events.Location;
@@ -23,6 +22,7 @@ import com.google.devtools.build.lib.syntax.SkylarkList.Tuple;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Formattable;
import java.util.Formatter;
import java.util.List;
@@ -232,7 +232,7 @@ public class Printer {
* @return the formatted string.
*/
public static Formattable formattable(final String pattern, Object... arguments) {
- final ImmutableList<Object> args = ImmutableList.copyOf(arguments);
+ final List<Object> args = Arrays.asList(arguments);
return new Formattable() {
@Override
public String toString() {
@@ -341,7 +341,9 @@ public class Printer {
@Override
public BasePrinter repr(Object o) {
if (o == null) {
- throw new NullPointerException(); // Java null is not a valid Skylark value.
+ // Java null is not a valid Skylark value, but sometimes printers are used on non-Skylark
+ // values such as Locations or ASTs.
+ this.append("null");
} else if (o instanceof SkylarkValue) {
((SkylarkValue) o).repr(this);
@@ -512,7 +514,7 @@ public class Printer {
*/
@Override
public BasePrinter format(String pattern, Object... arguments) {
- return this.formatWithList(pattern, ImmutableList.copyOf(arguments));
+ return this.formatWithList(pattern, Arrays.asList(arguments));
}
/**