Skip to content

Commit e3bccc6

Browse files
committed
Fix checkstyle.
1 parent 716725e commit e3bccc6

File tree

1 file changed

+16
-35
lines changed

1 file changed

+16
-35
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutorWithMocks.java

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,17 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
628628
when(context.getEnvironment()).thenReturn(env);
629629
Path workDir = new Path("/tmp");
630630

631+
LocalizerStartContext lsc = new LocalizerStartContext.Builder()
632+
.setNmPrivateContainerTokens(nmPrivateCTokensPath)
633+
.setNmAddr(address)
634+
.setUser(appSubmitter)
635+
.setAppId(appId.toString())
636+
.setLocId("12345")
637+
.setDirsHandler(dirService)
638+
.build();
639+
631640
try {
632-
lce.startLocalizer(new LocalizerStartContext.Builder()
633-
.setNmPrivateContainerTokens(nmPrivateCTokensPath)
634-
.setNmAddr(address)
635-
.setUser(appSubmitter)
636-
.setAppId(appId.toString())
637-
.setLocId("12345")
638-
.setDirsHandler(dirService)
639-
.build());
641+
lce.startLocalizer(lsc);
640642
Assert.fail("startLocalizer should have thrown an exception");
641643
} catch (IOException e) {
642644
assertTrue("Unexpected exception " + e,
@@ -648,30 +650,23 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
648650
LinuxContainerExecutor.ExitCode.INVALID_CONFIG_FILE.getExitCode(),
649651
};
650652

651-
for (int i = 0; i < exitCodesToThrow.length; i++) {
652-
int exitCode = exitCodesToThrow[i];
653+
for (int exitCode : exitCodesToThrow) {
653654
doThrow(new PrivilegedOperationException("invalid config", exitCode, null, null))
654655
.when(spyPrivilegedExecutor).executePrivilegedOperation(
655656
any(), any(PrivilegedOperation.class),
656657
any(), any(), anyBoolean(), anyBoolean());
657658

658659
try {
659-
lce.startLocalizer(new LocalizerStartContext.Builder()
660-
.setNmPrivateContainerTokens(nmPrivateCTokensPath)
661-
.setNmAddr(address)
662-
.setUser(appSubmitter)
663-
.setAppId(appId.toString())
664-
.setLocId("12345")
665-
.setDirsHandler(dirService)
666-
.build());
660+
lce.startLocalizer(lsc);
667661
Assert.fail("startLocalizer should have thrown a ConfigurationException");
668662
} catch (ConfigurationException e) {
669663
assertTrue("Unexpected exception " + e,
670664
e.getMessage().contains("exitCode=" + exitCode));
671665
}
672666
}
673667

674-
// Assert that we do catch an IOException thrown by the ProcessBuilder.start method as a misconfiguration
668+
// Assert that we do catch an IOException thrown by the ProcessBuilder.start
669+
// method as a misconfiguration
675670
String containerExecutorPath = lce.getContainerExecutorExecutablePath(conf);
676671
doThrow(new PrivilegedOperationException("IO error",
677672
new IOException("Cannot run program \""+ containerExecutorPath + "\"")))
@@ -680,14 +675,7 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
680675
any(), any(), anyBoolean(), anyBoolean());
681676

682677
try {
683-
lce.startLocalizer(new LocalizerStartContext.Builder()
684-
.setNmPrivateContainerTokens(nmPrivateCTokensPath)
685-
.setNmAddr(address)
686-
.setUser(appSubmitter)
687-
.setAppId(appId.toString())
688-
.setLocId("12345")
689-
.setDirsHandler(dirService)
690-
.build());
678+
lce.startLocalizer(lsc);
691679
Assert.fail("startLocalizer should have thrown an ConfigurationException");
692680
} catch (ConfigurationException e) {
693681
assertTrue("Unexpected exception " + e,
@@ -702,14 +690,7 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
702690
any(), any(), anyBoolean(), anyBoolean());
703691

704692
try {
705-
lce.startLocalizer(new LocalizerStartContext.Builder()
706-
.setNmPrivateContainerTokens(nmPrivateCTokensPath)
707-
.setNmAddr(address)
708-
.setUser(appSubmitter)
709-
.setAppId(appId.toString())
710-
.setLocId("12345")
711-
.setDirsHandler(dirService)
712-
.build());
693+
lce.startLocalizer(lsc);
713694
Assert.fail("startLocalizer should have thrown an IOException");
714695
} catch (ConfigurationException e) {
715696
Assert.fail("startLocalizer should not have thrown a ConfigurationException");

0 commit comments

Comments
 (0)