From 6eb700ee7469cd77524676d62cbd20043f111288 Mon Sep 17 00:00:00 2001 From: Konstantin V Shvachko Date: Fri, 23 Sep 2016 11:25:15 -0700 Subject: [PATCH] HDFS-10866. Fix Eclipse Java compile errors related to generic parameters. Contributed by Konstantin Shvachko. --- .../java/org/apache/hadoop/io/MapFile.java | 4 +-- .../hadoop/fs/TestDelegationTokenRenewer.java | 3 +-- .../hadoop/hdfs/web/TestWebHdfsTokens.java | 27 +++++++++---------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/MapFile.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/MapFile.java index ee76458b5d..96a4189092 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/MapFile.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/MapFile.java @@ -990,8 +990,8 @@ public static void main(String[] args) throws Exception { reader.getKeyClass().asSubclass(WritableComparable.class), reader.getValueClass()); - WritableComparable key = ReflectionUtils.newInstance(reader.getKeyClass() - .asSubclass(WritableComparable.class), conf); + WritableComparable key = ReflectionUtils.newInstance( + reader.getKeyClass().asSubclass(WritableComparable.class), conf); Writable value = ReflectionUtils.newInstance(reader.getValueClass() .asSubclass(Writable.class), conf); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java index 6b66222b29..582bc3142c 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java @@ -49,7 +49,6 @@ public void setup() { renewer = DelegationTokenRenewer.getInstance(); } - @SuppressWarnings("unchecked") @Test public void testAddRemoveRenewAction() throws IOException, InterruptedException { @@ -81,7 +80,7 @@ public Long answer(InvocationOnMock invocation) { verify(token).cancel(eq(conf)); verify(fs, never()).getDelegationToken(null); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); assertEquals("FileSystem not removed from DelegationTokenRenewer", 0, renewer.getRenewQueueLength()); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTokens.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTokens.java index 6192ad927f..058f63f8b7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTokens.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTokens.java @@ -127,7 +127,7 @@ private void checkNoTokenForOperation(HttpOpParam.Op op) throws IOException { fs.toUrl(op, null); verify(fs, never()).getDelegationToken(); verify(fs, never()).getDelegationToken(null); - verify(fs, never()).setDelegationToken((Token)any(Token.class)); + verify(fs, never()).setDelegationToken(any()); } @Test(timeout = 1000) @@ -160,7 +160,6 @@ public void testDeleteOpRequireAuth() { } } - @SuppressWarnings("unchecked") // for any(Token.class) @Test public void testLazyTokenFetchForWebhdfs() throws Exception { MiniDFSCluster cluster = null; @@ -190,7 +189,6 @@ public void testLazyTokenFetchForWebhdfs() throws Exception { } } - @SuppressWarnings("unchecked") // for any(Token.class) @Test public void testLazyTokenFetchForSWebhdfs() throws Exception { MiniDFSCluster cluster = null; @@ -298,7 +296,6 @@ Token decodeResponse(Map json) } } - @SuppressWarnings("unchecked") private void validateLazyTokenFetch(final Configuration clusterConf) throws Exception{ final String testUser = "DummyUser"; UserGroupInformation ugi = UserGroupInformation.createUserForTesting( @@ -316,7 +313,7 @@ public WebHdfsFileSystem run() throws IOException { fs.cancelDelegationToken(token); verify(fs, never()).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); Assert.assertNull(fs.getRenewToken()); reset(fs); @@ -326,7 +323,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, times(1)).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); verify(fs, times(1)).getDelegationToken(anyString()); - verify(fs, times(1)).setDelegationToken(any(Token.class)); + verify(fs, times(1)).setDelegationToken(any()); token = fs.getRenewToken(); Assert.assertNotNull(token); Assert.assertEquals(testUser, getTokenOwner(token)); @@ -338,7 +335,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, times(1)).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); verify(fs, never()).getDelegationToken(anyString()); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); Token token2 = fs.getRenewToken(); Assert.assertNotNull(token2); Assert.assertEquals(fs.getTokenKind(), token.getKind()); @@ -358,7 +355,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, never()).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); verify(fs, never()).getDelegationToken(anyString()); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); token2 = fs.getRenewToken(); Assert.assertNotNull(token2); Assert.assertEquals(fs.getTokenKind(), token.getKind()); @@ -376,7 +373,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, never()).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); verify(fs, never()).getDelegationToken(anyString()); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); token2 = fs.getRenewToken(); Assert.assertNotNull(token2); Assert.assertEquals(fs.getTokenKind(), token.getKind()); @@ -390,7 +387,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, times(2)).getDelegationToken(); // first bad, then good verify(fs, times(1)).replaceExpiredDelegationToken(); verify(fs, times(1)).getDelegationToken(null); - verify(fs, times(1)).setDelegationToken(any(Token.class)); + verify(fs, times(1)).setDelegationToken(any()); token2 = fs.getRenewToken(); Assert.assertNotNull(token2); Assert.assertNotSame(token, token2); @@ -407,7 +404,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, times(2)).getDelegationToken(); // first bad, then good verify(fs, times(1)).replaceExpiredDelegationToken(); verify(fs, times(1)).getDelegationToken(null); - verify(fs, times(1)).setDelegationToken(any(Token.class)); + verify(fs, times(1)).setDelegationToken(any()); token2 = fs.getRenewToken(); Assert.assertNotNull(token2); Assert.assertNotSame(token, token2); @@ -420,7 +417,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, never()).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); verify(fs, never()).getDelegationToken(anyString()); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); verify(fs, times(1)).cancelDelegationToken(eq(token2)); // add a token to ugi for a new fs, verify it uses that token @@ -449,7 +446,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, times(1)).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); verify(fs, never()).getDelegationToken(anyString()); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); token2 = fs.getRenewToken(); Assert.assertNotNull(token2); Assert.assertEquals(fs.getTokenKind(), token.getKind()); @@ -469,7 +466,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, times(1)).getDelegationToken(); verify(fs, times(1)).replaceExpiredDelegationToken(); verify(fs, never()).getDelegationToken(anyString()); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); token2 = fs.getRenewToken(); Assert.assertNotNull(token2); Assert.assertEquals(fs.getTokenKind(), token.getKind()); @@ -482,7 +479,7 @@ public WebHdfsFileSystem run() throws IOException { verify(fs, never()).getDelegationToken(); verify(fs, never()).replaceExpiredDelegationToken(); verify(fs, never()).getDelegationToken(anyString()); - verify(fs, never()).setDelegationToken(any(Token.class)); + verify(fs, never()).setDelegationToken(any()); verify(fs, never()).cancelDelegationToken(any(Token.class)); }