Skip to content

Commit

Permalink
Remove our own usages of Apache Commons Lang and replace them with Gu…
Browse files Browse the repository at this point in the history
…ava.

This means the last remaining use is Apache Velocity, which we hopefully can also remove somehow.

RELNOTES:
PiperOrigin-RevId: 352604027
  • Loading branch information
philwo authored and copybara-github committed Jan 19, 2021
1 parent 039461c commit 052e5f8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/lib/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ java_library(
deps = [
"//src/main/java/com/google/devtools/build/lib/actions:localhost_capacity",
"//src/main/java/com/google/devtools/common/options",
"//third_party:apache_commons_lang",
"//third_party:guava",
"//third_party:jsr305",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.devtools.build.lib.util;

import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Ints;
import com.google.devtools.build.lib.actions.LocalHostCapacity;
import com.google.devtools.common.options.Converters;
import com.google.devtools.common.options.OptionsParsingException;
Expand All @@ -24,7 +25,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.apache.commons.lang.math.NumberUtils;

/**
* Converter for options that configure Bazel's resource usage.
Expand Down Expand Up @@ -112,7 +112,7 @@ public ResourceConverter(
@Override
public final Integer convert(String input) throws OptionsParsingException {
int value;
if (NumberUtils.isNumber(input)) {
if (Ints.tryParse(input) != null) {
value = super.convert(input);
return checkAndLimit(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -91,7 +92,6 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;
import javax.annotation.Nullable;
import org.apache.commons.lang.time.StopWatch;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -565,8 +565,7 @@ public void testConcurrency() throws Exception {
public void concurrencyBenchmark() throws Exception {
long time = 0;
for (int iteration = 0; iteration < 3; iteration++) {
StopWatch watch = new StopWatch();
watch.start();
Stopwatch watch = Stopwatch.createStarted();

BuildEvent startEvent =
new GenericBuildEvent(
Expand Down Expand Up @@ -600,7 +599,7 @@ public void concurrencyBenchmark() throws Exception {
pool.awaitTermination(1, TimeUnit.DAYS);
watch.stop();

time += watch.getTime();
time += watch.elapsed().toMillis();

BuildEventId lateId = testId("late event");
streamer.buildEvent(new BuildCompleteEvent(new BuildResult(0), ImmutableList.of(lateId)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void convertFloat_throwsException() {
resourceConverter = new ResourceConverter(() -> null);
OptionsParsingException thrown =
assertThrows(OptionsParsingException.class, () -> resourceConverter.convert(".5"));
assertThat(thrown).hasMessageThat().contains("not an int");
assertThat(thrown).hasMessageThat().contains("This flag takes an integer");
}

@Test
Expand Down

0 comments on commit 052e5f8

Please sign in to comment.