Merge with default

This commit is contained in:
Rene Pfeuffer
2019-12-05 10:53:33 +01:00
104 changed files with 912 additions and 505 deletions

View File

@@ -88,14 +88,16 @@ public class BootstrapContextListener extends GuiceServletContextListener {
protected Injector getInjector() {
Throwable startupError = SCMContext.getContext().getStartupError();
if (startupError != null) {
LOG.error("received unrecoverable error during startup", startupError);
return createStageOneInjector(SingleView.error(startupError));
} else if (Versions.isTooOld()) {
LOG.error("Existing version is too old and cannot be migrated to new version. Please update to version {} first", Versions.MIN_VERSION);
LOG.error("existing version is too old and cannot be migrated to new version. Please update to version {} first", Versions.MIN_VERSION);
return createStageOneInjector(SingleView.view("/templates/too-old.mustache", HttpServletResponse.SC_CONFLICT));
} else {
try {
return createStageTwoInjector();
} catch (Exception ex) {
LOG.error("failed to create stage two injector", ex);
return createStageOneInjector(SingleView.error(ex));
}
}

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

@@ -248,6 +248,7 @@ public class DefaultPluginManager implements PluginManager {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
eventBus.post(new RestartEvent(PluginManager.class, cause));
}).start();

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

@@ -53,7 +53,7 @@ public final class PluginCenterDto implements Serializable {
private String category;
private String author;
private String avatarUrl;
private String sha256;
private String sha256sum;
@XmlElement(name = "conditions")
private Condition conditions;

View File

@@ -19,7 +19,7 @@ public abstract class PluginCenterDtoMapper {
for (PluginCenterDto.Plugin plugin : pluginCenterDto.getEmbedded().getPlugins()) {
String url = plugin.getLinks().get("download").getHref();
AvailablePluginDescriptor descriptor = new AvailablePluginDescriptor(
map(plugin), map(plugin.getConditions()), plugin.getDependencies(), url, plugin.getSha256()
map(plugin), map(plugin.getConditions()), plugin.getDependencies(), url, plugin.getSha256sum()
);
plugins.add(new AvailablePlugin(descriptor));
}

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 -------------------------------------------------------------