merge with default branch

This commit is contained in:
Sebastian Sdorra
2019-11-27 15:01:09 +01:00
39 changed files with 116 additions and 221 deletions

View File

@@ -102,7 +102,6 @@ import javax.xml.transform.stream.StreamResult;
import static javax.lang.model.util.ElementFilter.methodsIn;
/**
*
* @author Sebastian Sdorra
*/
@SupportedAnnotationTypes("*")
@@ -376,11 +375,14 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
}
// add default values
for (ExecutableElement meth : methodsIn(am.getAnnotationType().asElement().getEnclosedElements())) {
for (ExecutableElement meth : methodsIn(annotationMirror.getAnnotationType().asElement().getEnclosedElements())) {
String attribute = meth.getSimpleName().toString();
AnnotationValue defaultValue = meth.getDefaultValue();
if (defaultValue != null && !attributes.containsKey(attribute)) {
attributes.put(attribute, getValue(defaultValue));
String value = getValue(defaultValue);
if (value != null && !value.isEmpty()) {
attributes.put(attribute, value);
}
}
}
}

View File

@@ -8,8 +8,7 @@
<artifactId>scm</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>sonia.scm</groupId>
<artifactId>scm-annotations</artifactId>
<version>2.0.0-SNAPSHOT</version>
<name>scm-annotations</name>

View File

@@ -134,7 +134,7 @@ public final class IterableQueue<T> implements Iterable<T>
else
{
logger.trace("create queue iterator");
iterator = new QueueIterator<T>(this);
iterator = new QueueIterator<>(this);
}
return iterator;

View File

@@ -63,7 +63,7 @@ public class LimitedSortedSet<E> extends ForwardingSortedSet<E>
*/
public LimitedSortedSet(int maxSize)
{
this.sortedSet = new TreeSet<E>();
this.sortedSet = new TreeSet<>();
this.maxSize = maxSize;
}

View File

@@ -183,5 +183,5 @@ public abstract class AbstractResourceProcessor implements ResourceProcessor
//~--- fields ---------------------------------------------------------------
/** Field description */
private Map<String, String> variableMap = new HashMap<String, String>();
private Map<String, String> variableMap = new HashMap<>();
}

View File

@@ -52,7 +52,7 @@ public class INIConfiguration
*/
public INIConfiguration()
{
this.sectionMap = new LinkedHashMap<String, INISection>();
this.sectionMap = new LinkedHashMap<>();
}
//~--- methods --------------------------------------------------------------

View File

@@ -55,7 +55,7 @@ public class INISection
public INISection(String name)
{
this.name = name;
this.parameters = new LinkedHashMap<String, String>();
this.parameters = new LinkedHashMap<>();
}
/**

View File

@@ -46,7 +46,7 @@ public final class Base32 extends AbstractBase
{
/** base value */
private static final BigInteger BASE = BigInteger.valueOf(32l);
private static final BigInteger BASE = BigInteger.valueOf(32L);
/** char table */
private static final String CHARS = "0123456789bcdefghjkmnpqrstuvwxyz";

View File

@@ -46,7 +46,7 @@ public final class Base62 extends AbstractBase
{
/** base value */
private static final BigInteger BASE = BigInteger.valueOf(62l);
private static final BigInteger BASE = BigInteger.valueOf(62L);
/** char table */
private static final String CHARS =

View File

@@ -79,7 +79,7 @@ public final class LinkTextParser
public static String parseText(String content)
{
Matcher m = REGEX_URL.matcher(content);
List<Token> tokens = new ArrayList<Token>();
List<Token> tokens = new ArrayList<>();
int position = 0;
String tokenContent = null;

View File

@@ -119,7 +119,7 @@ public final class ServiceUtil
*/
public static <T> List<T> getServices(Class<T> type)
{
List<T> result = new ArrayList<T>();
List<T> result = new ArrayList<>();
try
{

View File

@@ -38,23 +38,12 @@ package sonia.scm.util;
import com.google.common.base.Strings;
import com.google.common.collect.Multimap;
//~--- JDK imports ------------------------------------------------------------
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
//~--- JDK imports ------------------------------------------------------------
/**
*
@@ -273,12 +262,12 @@ public final class Util
Comparator<T> comparator, CollectionAppender<T> appender, int start,
int limit)
{
List<T> result = new ArrayList<T>();
List<T> valueList = new ArrayList<T>(values);
List<T> result = new ArrayList<>();
List<T> valueList = new ArrayList<>(values);
if (comparator != null)
{
Collections.sort(valueList, comparator);
valueList.sort(comparator);
}
int length = valueList.size();
@@ -506,12 +495,10 @@ public final class Util
{
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < byteValue.length; i++)
{
int x = byteValue[i] & 0xff;
for (final byte aByteValue : byteValue) {
int x = aByteValue & 0xff;
if (x < 16)
{
if (x < 16) {
buffer.append('0');
}

View File

@@ -66,7 +66,7 @@ public class EnvList
*/
public EnvList()
{
envMap = new HashMap<String, String>();
envMap = new HashMap<>();
}
/**
@@ -77,7 +77,7 @@ public class EnvList
*/
public EnvList(EnvList l)
{
envMap = new HashMap<String, String>(l.envMap);
envMap = new HashMap<>(l.envMap);
}
//~--- methods --------------------------------------------------------------

View File

@@ -470,13 +470,13 @@ public class BufferedHttpServletResponse extends HttpServletResponseWrapper
private ByteArrayPrintWriter pw = null;
/** Field description */
private Set<Cookie> cookies = new HashSet<Cookie>();
private Set<Cookie> cookies = new HashSet<>();
/** Field description */
private int statusCode = HttpServletResponse.SC_OK;
/** Field description */
private Map<String, String> headers = new LinkedHashMap<String, String>();
private Map<String, String> headers = new LinkedHashMap<>();
/** Field description */
private String statusMessage;

View File

@@ -40,28 +40,20 @@ import com.google.common.io.ByteStreams;
import com.google.common.io.Closer;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//~--- JDK imports ------------------------------------------------------------
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//~--- JDK imports ------------------------------------------------------------
/**
*
@@ -175,10 +167,8 @@ public class ProxyServlet extends HttpServlet
private void copyContent(HttpURLConnection con, HttpServletResponse response)
throws IOException
{
Closer closer = Closer.create();
try
{
try (Closer closer = Closer.create()) {
InputStream webToProxyBuf =
closer.register(new BufferedInputStream(con.getInputStream()));
OutputStream proxyToClientBuf =
@@ -188,10 +178,6 @@ public class ProxyServlet extends HttpServlet
logger.trace("copied {} bytes for proxy", bytes);
}
finally
{
closer.close();
}
}
/**

View File

@@ -102,7 +102,7 @@ public class XmlMapStringAdapter
public Map<String, String> unmarshal(XmlMapStringElement[] elements)
throws Exception
{
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
if (elements != null)
{

View File

@@ -90,7 +90,7 @@ public class XmlSetStringAdapter extends XmlAdapter<String, Set<String>>
@Override
public Set<String> unmarshal(String rawString) throws Exception
{
Set<String> tokens = new HashSet<String>();
Set<String> tokens = new HashSet<>();
for (String token : rawString.split(","))
{

View File

@@ -63,7 +63,7 @@ public class IterableQueueTest
@Test(expected = IllegalStateException.class)
public void testDuplicatedEndReached()
{
IterableQueue<String> queue = new IterableQueue<String>();
IterableQueue<String> queue = new IterableQueue<>();
queue.endReached();
queue.endReached();
@@ -76,7 +76,7 @@ public class IterableQueueTest
@Test
public void testIterator()
{
IterableQueue<String> queue = new IterableQueue<String>();
IterableQueue<String> queue = new IterableQueue<>();
assertEquals(QueueIterator.class, queue.iterator().getClass());
queue.endReached();
@@ -120,7 +120,7 @@ public class IterableQueueTest
@Test(expected = IllegalStateException.class)
public void testPushEndReached()
{
IterableQueue<String> queue = new IterableQueue<String>();
IterableQueue<String> queue = new IterableQueue<>();
queue.push("a");
queue.endReached();
@@ -134,7 +134,7 @@ public class IterableQueueTest
@Test
public void testSingleConsumer()
{
final IterableQueue<Integer> queue = new IterableQueue<Integer>();
final IterableQueue<Integer> queue = new IterableQueue<>();
new Thread(new IntegerProducer(queue, false, 100)).start();
assertResult(Lists.newArrayList(queue), 100);
@@ -176,12 +176,12 @@ public class IterableQueueTest
ExecutorService executor = Executors.newFixedThreadPool(threads);
List<Future<List<Integer>>> futures = Lists.newArrayList();
final IterableQueue<Integer> queue = new IterableQueue<Integer>();
final IterableQueue<Integer> queue = new IterableQueue<>();
for (int i = 0; i < consumer; i++)
{
Future<List<Integer>> future =
executor.submit(new CallableQueueCollector<Integer>(queue));
executor.submit(new CallableQueueCollector<>(queue));
futures.add(future);
}

View File

@@ -71,8 +71,8 @@ public class ScmModuleTest
assertThat(
module.getExtensions(),
containsInAnyOrder(
(Class<?>) String.class,
(Class<?>) Integer.class
String.class,
Integer.class
)
);
assertThat(
@@ -86,8 +86,8 @@ public class ScmModuleTest
assertThat(
module.getEvents(),
containsInAnyOrder(
(Class<?>) String.class,
(Class<?>) Boolean.class
String.class,
Boolean.class
)
);
assertThat(
@@ -100,15 +100,15 @@ public class ScmModuleTest
assertThat(
module.getRestProviders(),
containsInAnyOrder(
(Class<?>) Integer.class,
(Class<?>) Long.class
Integer.class,
Long.class
)
);
assertThat(
module.getRestResources(),
containsInAnyOrder(
(Class<?>) Float.class,
(Class<?>) Double.class
Float.class,
Double.class
)
);
//J+

View File

@@ -128,7 +128,7 @@ public class TemplateEngineFactoryTest
assertTrue(engines.contains(engine1));
assertTrue(engines.contains(engine2));
Set<TemplateEngine> ce = new HashSet<TemplateEngine>();
Set<TemplateEngine> ce = new HashSet<>();
ce.add(engine1);
factory = new TemplateEngineFactory(ce, engine2);

View File

@@ -56,7 +56,7 @@ public class UrlBuilderTest
UrlBuilder builder = new UrlBuilder("http://www.short.de");
builder.appendParameter("i", 123).appendParameter("s", "abc");
builder.appendParameter("b", true).appendParameter("l", 321l);
builder.appendParameter("b", true).appendParameter("l", 321L);
assertEquals("http://www.short.de?i=123&s=abc&b=true&l=321", builder.toString());
builder.appendParameter("c", "a b");
assertEquals("http://www.short.de?i=123&s=abc&b=true&l=321&c=a%20b", builder.toString());

View File

@@ -199,7 +199,7 @@ public class XmlGroupDatabase implements XmlDatabase<Group>
/** Field description */
@XmlJavaTypeAdapter(XmlGroupMapAdapter.class)
@XmlElement(name = "groups")
private Map<String, Group> groupMap = new LinkedHashMap<String, Group>();
private Map<String, Group> groupMap = new LinkedHashMap<>();
/** Field description */
private Long lastModified;

View File

@@ -72,7 +72,7 @@ public class XmlGroupList implements Iterable<Group>
*/
public XmlGroupList(Map<String, Group> groupMap)
{
this.groups = new LinkedList<Group>(groupMap.values());
this.groups = new LinkedList<>(groupMap.values());
}
//~--- methods --------------------------------------------------------------

View File

@@ -81,7 +81,7 @@ public class XmlGroupMapAdapter
@Override
public Map<String, Group> unmarshal(XmlGroupList groups) throws Exception
{
Map<String, Group> groupMap = new LinkedHashMap<String, Group>();
Map<String, Group> groupMap = new LinkedHashMap<>();
for (Group group : groups)
{

View File

@@ -202,5 +202,5 @@ public class XmlUserDatabase implements XmlDatabase<User>
/** Field description */
@XmlJavaTypeAdapter(XmlUserMapAdapter.class)
@XmlElement(name = "users")
private Map<String, User> userMap = new LinkedHashMap<String, User>();
private Map<String, User> userMap = new LinkedHashMap<>();
}

View File

@@ -72,7 +72,7 @@ public class XmlUserList implements Iterable<User>
*/
public XmlUserList(Map<String, User> userMap)
{
this.users = new LinkedList<User>(userMap.values());
this.users = new LinkedList<>(userMap.values());
}
//~--- methods --------------------------------------------------------------

View File

@@ -81,7 +81,7 @@ public class XmlUserMapAdapter
@Override
public Map<String, User> unmarshal(XmlUserList users) throws Exception
{
Map<String, User> userMap = new LinkedHashMap<String, User>();
Map<String, User> userMap = new LinkedHashMap<>();
for (User user : users)
{

View File

@@ -145,7 +145,7 @@ public class HgPackageReader
*/
private void filterPackage(HgPackages packages)
{
List<HgPackage> pkgList = new ArrayList<HgPackage>();
List<HgPackage> pkgList = new ArrayList<>();
for (HgPackage pkg : packages)
{
@@ -228,7 +228,7 @@ public class HgPackageReader
if (packages == null)
{
packages = new HgPackages();
packages.setPackages(new ArrayList<HgPackage>());
packages.setPackages(new ArrayList<>());
}
return packages;

View File

@@ -211,15 +211,7 @@ public class SVNKitLogger extends SVNDebugLogAdapter
*/
private Logger getLogger(SVNLogType type)
{
Logger logger = loggerMap.get(type);
if (logger == null)
{
logger = LoggerFactory.getLogger(parseName(type.getName()));
loggerMap.put(type, logger);
}
return logger;
return loggerMap.computeIfAbsent(type, t -> LoggerFactory.getLogger(parseName(t.getName())));
}
//~--- fields ---------------------------------------------------------------

View File

@@ -81,15 +81,7 @@ public class MapCacheManager
@Override
public synchronized <K, V> MapCache<K, V> getCache(String name)
{
MapCache<K, V> cache = cacheMap.get(name);
if (cache == null)
{
cache = new MapCache<K, V>();
cacheMap.put(name, cache);
}
return cache;
return (MapCache<K, V>) cacheMap.computeIfAbsent(name, k -> new MapCache<K, V>());
}
//~--- fields ---------------------------------------------------------------

View File

@@ -38,39 +38,27 @@ import com.google.common.base.Strings;
import com.google.common.collect.Multimap;
import com.google.common.io.Closeables;
import com.google.inject.Inject;
import org.apache.shiro.codec.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.net.Proxies;
import sonia.scm.net.TrustAllHostnameVerifier;
import sonia.scm.net.TrustAllTrustManager;
import sonia.scm.util.HttpUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.SocketAddress;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Set;
import javax.inject.Provider;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import java.io.IOException;
import java.io.OutputStream;
import java.net.*;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Set;
//~--- JDK imports ------------------------------------------------------------
/**
* Default implementation of the {@link AdvancedHttpClient}. The default
@@ -324,11 +312,7 @@ public class DefaultAdvancedHttpClient extends AdvancedHttpClient
sc.init(null, trustAllCerts, new java.security.SecureRandom());
connection.setSSLSocketFactory(sc.getSocketFactory());
}
catch (KeyManagementException ex)
{
logger.error("could not disable certificate validation", ex);
}
catch (NoSuchAlgorithmException ex)
catch (KeyManagementException | NoSuchAlgorithmException ex)
{
logger.error("could not disable certificate validation", ex);
}

View File

@@ -34,20 +34,17 @@ package sonia.scm.net.ahc;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.ByteSource;
import sonia.scm.plugin.Extension;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
import javax.ws.rs.core.MediaType;
import javax.xml.bind.DataBindingException;
import javax.xml.bind.JAXB;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.DataBindingException;
import javax.xml.bind.JAXB;
//~--- JDK imports ------------------------------------------------------------
/**
* {@link ContentTransformer} for xml. The {@link XmlContentTransformer} uses
@@ -96,15 +93,10 @@ public class XmlContentTransformer implements ContentTransformer
stream = content.openBufferedStream();
object = JAXB.unmarshal(stream, type);
}
catch (IOException ex)
catch (IOException | DataBindingException ex)
{
throw new ContentTransformerException("could not unmarshall content", ex);
}
catch (DataBindingException ex)
{
throw new ContentTransformerException("could not unmarshall content", ex);
}
finally
} finally
{
IOUtil.close(stream);
}

View File

@@ -74,7 +74,7 @@ public class MultiParentClassLoader extends ClassLoader
public MultiParentClassLoader(Collection<? extends ClassLoader> parents)
{
super(null);
this.parents = new CopyOnWriteArrayList<ClassLoader>(parents);
this.parents = new CopyOnWriteArrayList<>(parents);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -128,15 +128,7 @@ public class HealthCheckContextListener implements ServletContextListener
{
// excute health checks for all repsitories asynchronous
SecurityUtils.getSubject().execute(new Runnable()
{
@Override
public void run()
{
healthChecker.checkAll();
}
});
SecurityUtils.getSubject().execute(healthChecker::checkAll);
}
//~--- fields -------------------------------------------------------------

View File

@@ -35,18 +35,14 @@ package sonia.scm.cache;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Predicate;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import sonia.scm.util.IOUtil;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.*;
import org.junit.Assume;
/**
*
@@ -166,14 +162,7 @@ public abstract class CacheTestBase
cache.put("a-1", "test123");
cache.put("a-2", "test123");
Iterable<String> previous = cache.removeAll(new Predicate<String>()
{
@Override
public boolean apply(String item)
{
return item.startsWith("test");
}
});
Iterable<String> previous = cache.removeAll(item -> item != null && item.startsWith("test"));
assertThat(previous, containsInAnyOrder("test123", "test456"));
assertNull(cache.get("test-1"));
@@ -188,8 +177,8 @@ public abstract class CacheTestBase
// skip test if implementation does not support stats
Assume.assumeTrue( stats != null );
assertEquals("test", stats.getName());
assertEquals(0l, stats.getHitCount());
assertEquals(0l, stats.getMissCount());
assertEquals(0L, stats.getHitCount());
assertEquals(0L, stats.getMissCount());
cache.put("test-1", "test123");
cache.put("test-2", "test456");
cache.get("test-1");
@@ -197,11 +186,11 @@ public abstract class CacheTestBase
cache.get("test-1");
cache.get("test-3");
// check that stats have not changed
assertEquals(0l, stats.getHitCount());
assertEquals(0l, stats.getMissCount());
assertEquals(0L, stats.getHitCount());
assertEquals(0L, stats.getMissCount());
stats = cache.getStatistics();
assertEquals(3l, stats.getHitCount());
assertEquals(1l, stats.getMissCount());
assertEquals(3L, stats.getHitCount());
assertEquals(1L, stats.getMissCount());
assertEquals(0.75d, stats.getHitRate(), 0.0d);
assertEquals(0.25d, stats.getMissRate(), 0.0d);
}

View File

@@ -63,7 +63,7 @@ public class GuavaConfigurationReaderTest
GuavaCacheConfiguration cfg =
readConfiguration("gcache.001.xml").getDefaultCache();
assertCacheValues(cfg, 200l, 1200l, 2400l);
assertCacheValues(cfg, 200L, 1200L, 2400L);
}
/**
@@ -82,10 +82,10 @@ public class GuavaConfigurationReaderTest
//J+
// cache sonia.test.cache.001 override by cache.004.xml
assertCacheValues(getCache(gcm, "sonia.test.cache.001"), 6l, 2l, 8l);
assertCacheValues(getCache(gcm, "sonia.test.cache.002"), 1000l, 120l, 60l);
assertCacheValues(getCache(gcm, "sonia.test.cache.003"), 3000l, 120l,
2400l);
assertCacheValues(getCache(gcm, "sonia.test.cache.001"), 6L, 2L, 8L);
assertCacheValues(getCache(gcm, "sonia.test.cache.002"), 1000L, 120L, 60L);
assertCacheValues(getCache(gcm, "sonia.test.cache.003"), 3000L, 120L,
2400L);
}
/**
@@ -100,8 +100,8 @@ public class GuavaConfigurationReaderTest
// check default
assertCacheValues(getCache(gcm, "sonia.test.cache.001"), 1000l, 60l, 30l);
assertCacheValues(getCache(gcm, "sonia.test.cache.002"), 1000l, 120l, 60l);
assertCacheValues(getCache(gcm, "sonia.test.cache.001"), 1000L, 60L, 30L);
assertCacheValues(getCache(gcm, "sonia.test.cache.002"), 1000L, 120L, 60L);
}
/**
@@ -115,10 +115,10 @@ public class GuavaConfigurationReaderTest
Iterators.forArray("gcache.002.xml",
"gcache.003.xml"));
assertCacheValues(getCache(gcm, "sonia.test.cache.001"), 1000l, 60l, 30l);
assertCacheValues(getCache(gcm, "sonia.test.cache.002"), 1000l, 120l, 60l);
assertCacheValues(getCache(gcm, "sonia.test.cache.003"), 3000l, 120l,
2400l);
assertCacheValues(getCache(gcm, "sonia.test.cache.001"), 1000L, 60L, 30L);
assertCacheValues(getCache(gcm, "sonia.test.cache.002"), 1000L, 120L, 60L);
assertCacheValues(getCache(gcm, "sonia.test.cache.003"), 3000L, 120L,
2400L);
}
/**
@@ -131,7 +131,7 @@ public class GuavaConfigurationReaderTest
GuavaCacheConfiguration cfg =
readConfiguration("gcache.001.xml").getCaches().get(0);
assertCacheValues(cfg, 1000l, 60l, 30l);
assertCacheValues(cfg, 1000L, 60L, 30L);
}
/**
@@ -144,7 +144,7 @@ public class GuavaConfigurationReaderTest
GuavaCacheConfiguration cfg =
readConfiguration("gcache.002.xml").getCaches().get(0);
assertCacheValues(cfg, 1000l, 120l, 60l);
assertCacheValues(cfg, 1000L, 120L, 60L);
}
/**

View File

@@ -74,7 +74,7 @@ public class ConfigurableLoginAttemptHandlerTest {
handler.onUnsuccessfulAuthentication(token, new SimpleAuthenticationInfo());
handler.beforeAuthentication(token);
handler.onUnsuccessfulAuthentication(token, new SimpleAuthenticationInfo());
Thread.sleep(TimeUnit.MILLISECONDS.toMillis(1200l));
Thread.sleep(TimeUnit.MILLISECONDS.toMillis(1200L));
handler.beforeAuthentication(token);
}
@@ -111,4 +111,4 @@ public class ConfigurableLoginAttemptHandlerTest {
return new ConfigurableLoginAttemptHandler(configuration);
}
}
}

View File

@@ -35,22 +35,15 @@ package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Sets;
import org.junit.Test;
import java.util.Set;
import java.util.concurrent.*;
import static org.junit.Assert.*;
//~--- JDK imports ------------------------------------------------------------
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
*
* @author Sebastian Sdorra
@@ -96,28 +89,22 @@ public class DefaultKeyGeneratorTest
for (int i = 0; i < 10; i++)
{
Future<Set<String>> future = executor.submit(new Callable<Set<String>>()
{
Future<Set<String>> future = executor.submit(() -> {
Set<String> keys = Sets.newHashSet();
@Override
public Set<String> call()
for (int i1 = 0; i1 < 1000; i1++)
{
Set<String> keys = Sets.newHashSet();
String key = generator.createKey();
for (int i = 0; i < 1000; i++)
if (keys.contains(key))
{
String key = generator.createKey();
if (keys.contains(key))
{
fail("dublicate key");
}
keys.add(key);
fail("dublicate key");
}
return keys;
keys.add(key);
}
return keys;
});
futureSet.add(future);

View File

@@ -89,15 +89,8 @@ public class MustacheTemplateTest extends TemplateTestBase
@Override
protected void prepareEnv(Map<String, Object> env)
{
env.put("test", new Function<String, String>()
{
@Override
public String apply(String input)
{
throw new UnsupportedOperationException("Not supported yet.");
}
env.put("test", (Function<String, String>) input -> {
throw new UnsupportedOperationException("Not supported yet.");
});
}