keith-turner commented on a change in pull request #2530: URL: https://github.com/apache/accumulo/pull/2530#discussion_r816047869
########## File path: core/src/test/java/org/apache/accumulo/core/util/threads/AccumuloUncaughtExceptionHandlerTest.java ########## @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.core.util.threads; + +import static org.apache.accumulo.core.util.threads.AccumuloUncaughtExceptionHandler.isError; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.io.UncheckedIOException; + +import org.junit.Test; + +public class AccumuloUncaughtExceptionHandlerTest { + + @Test + public void testIsError() { + assertFalse(isError(new IOException())); + assertFalse(isError(new UncheckedIOException(new IOException()))); + + Exception e = new UncheckedIOException(new IOException()); + e.addSuppressed(new RuntimeException()); + e.addSuppressed(new RuntimeException()); + assertFalse(isError(e)); + + assertTrue(isError(new UnsatisfiedLinkError())); + assertTrue(isError(new RuntimeException(new UnsatisfiedLinkError()))); + assertTrue(isError(new RuntimeException(new RuntimeException(new UnsatisfiedLinkError())))); + + e.addSuppressed(new RuntimeException(new UnsatisfiedLinkError())); + assertTrue(isError(e)); + assertTrue(isError(new RuntimeException(e))); Review comment: > Minimally, you could use a new variable to make the two test scenarios independent I was trying to avoid duplicating code, but that does make the test less maintainable. I redid the test a bit and duplicated code. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
