Skip to content

Commit 62c86ea

Browse files
authored
HADOOP-17970. unguava: remove Preconditions from hdfs-projects modules (#3566)
1 parent 9cfd8d0 commit 62c86ea

File tree

248 files changed

+436
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+436
-274
lines changed

hadoop-hdfs-project/hadoop-hdfs-client/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,38 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
178178
<excludePackageNames>org.apache.hadoop.hdfs.protocol.proto</excludePackageNames>
179179
</configuration>
180180
</plugin>
181+
<plugin>
182+
<groupId>org.apache.maven.plugins</groupId>
183+
<artifactId>maven-enforcer-plugin</artifactId>
184+
<dependencies>
185+
<dependency>
186+
<groupId>de.skuzzle.enforcer</groupId>
187+
<artifactId>restrict-imports-enforcer-rule</artifactId>
188+
<version>${restrict-imports.enforcer.version}</version>
189+
</dependency>
190+
</dependencies>
191+
<executions>
192+
<execution>
193+
<id>banned-illegal-imports</id>
194+
<phase>process-sources</phase>
195+
<goals>
196+
<goal>enforce</goal>
197+
</goals>
198+
<configuration>
199+
<rules>
200+
<restrictImports implementation="de.skuzzle.enforcer.restrictimports.rule.RestrictImports">
201+
<includeTestCode>true</includeTestCode>
202+
<reason>Use hadoop-common provided VisibleForTesting rather than the one provided by Guava</reason>
203+
<bannedImports>
204+
<bannedImport>org.apache.hadoop.thirdparty.com.google.common.base.Preconditions</bannedImport>
205+
<bannedImport>com.google.common.base.Preconditions</bannedImport>
206+
</bannedImports>
207+
</restrictImports>
208+
</rules>
209+
</configuration>
210+
</execution>
211+
</executions>
212+
</plugin>
181213
</plugins>
182214
</build>
183215
</project>

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ClientContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.apache.hadoop.util.ReflectionUtils;
4444

4545
import org.apache.hadoop.classification.VisibleForTesting;
46-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
46+
import org.apache.hadoop.util.Preconditions;
4747

4848
import org.slf4j.Logger;
4949
import org.slf4j.LoggerFactory;

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196

197197
import org.apache.hadoop.classification.VisibleForTesting;
198198
import org.apache.hadoop.thirdparty.com.google.common.base.Joiner;
199-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
199+
import org.apache.hadoop.util.Preconditions;
200200
import org.apache.hadoop.thirdparty.com.google.common.net.InetAddresses;
201201

202202
/********************************************************

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
import org.slf4j.LoggerFactory;
7474

7575
import org.apache.hadoop.classification.VisibleForTesting;
76-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
76+
import org.apache.hadoop.util.Preconditions;
7777

7878
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.Write.RECOVER_LEASE_ON_CLOSE_EXCEPTION_DEFAULT;
7979
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.Write.RECOVER_LEASE_ON_CLOSE_EXCEPTION_KEY;

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.hadoop.hdfs;
1919

2020
import org.apache.hadoop.classification.VisibleForTesting;
21-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
21+
import org.apache.hadoop.util.Preconditions;
2222
import org.apache.hadoop.HadoopIllegalArgumentException;
2323
import org.apache.hadoop.classification.InterfaceAudience;
2424
import org.apache.hadoop.fs.CreateFlag;

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSUtilClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import org.apache.hadoop.net.DomainNameResolver;
2121
import org.apache.hadoop.thirdparty.com.google.common.base.Joiner;
22-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
22+
import org.apache.hadoop.util.Preconditions;
2323
import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
2424
import org.apache.hadoop.thirdparty.com.google.common.primitives.SignedBytes;
2525
import java.net.URISyntaxException;
@@ -145,7 +145,10 @@ public static byte[][] bytes2byteArray(byte[] bytes) {
145145
*/
146146
public static byte[][] bytes2byteArray(byte[] bytes, int len,
147147
byte separator) {
148-
Preconditions.checkPositionIndex(len, bytes.length);
148+
if (len < 0 || len > bytes.length) {
149+
throw new IndexOutOfBoundsException(
150+
"Incorrect index [len, size] [" + len + ", " + bytes.length + "]");
151+
}
149152
if (len == 0) {
150153
return new byte[][]{null};
151154
}

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.apache.hadoop.ipc.RpcNoSuchMethodException;
2323
import org.apache.hadoop.security.AccessControlException;
2424
import org.apache.hadoop.classification.VisibleForTesting;
25-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
25+
import org.apache.hadoop.util.Preconditions;
2626
import org.apache.commons.collections.list.TreeList;
2727
import org.apache.hadoop.HadoopIllegalArgumentException;
2828
import org.apache.hadoop.classification.InterfaceAudience;

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/NameNodeProxiesClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.slf4j.LoggerFactory;
3737

3838
import org.apache.hadoop.classification.VisibleForTesting;
39-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
39+
import org.apache.hadoop.util.Preconditions;
4040

4141
import org.apache.hadoop.conf.Configuration;
4242
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/PeerCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.Map.Entry;
2525

2626
import org.apache.hadoop.classification.VisibleForTesting;
27-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
27+
import org.apache.hadoop.util.Preconditions;
2828
import org.apache.hadoop.thirdparty.com.google.common.collect.LinkedListMultimap;
2929

3030
import org.apache.hadoop.classification.InterfaceAudience;

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/PositionStripeReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
package org.apache.hadoop.hdfs;
1919

20-
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
20+
import org.apache.hadoop.util.Preconditions;
2121
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
2222
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
2323
import org.apache.hadoop.hdfs.util.StripedBlockUtil;

0 commit comments

Comments
 (0)