Catch correct error for replaced class, to fix test errors. Satisfy checkstyle. #3061

This commit is contained in:
Mark H. Wood
2020-11-30 16:21:01 -05:00
parent ce4ca33346
commit a036b99f1c
5 changed files with 11 additions and 16 deletions

View File

@@ -10,10 +10,10 @@ package org.dspace.core;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@@ -157,8 +157,6 @@ public class Context implements AutoCloseable {
/** /**
* Initializes a new context object. * Initializes a new context object.
*
* @throws SQLException if there was an error obtaining a database connection
*/ */
protected void init() { protected void init() {
updateDatabase(); updateDatabase();
@@ -310,7 +308,7 @@ public class Context implements AutoCloseable {
Boolean previousState; Boolean previousState;
try { try {
previousState = authStateChangeHistory.pop(); previousState = authStateChangeHistory.pop();
} catch (EmptyStackException ex) { } catch (NoSuchElementException ex) {
log.warn(LogManager.getHeader(this, "restore_auth_sys_state", log.warn(LogManager.getHeader(this, "restore_auth_sys_state",
"not previous state info available " "not previous state info available "
+ ex.getLocalizedMessage())); + ex.getLocalizedMessage()));
@@ -325,8 +323,7 @@ public class Context implements AutoCloseable {
// if previousCaller is not the current caller *only* log a warning // if previousCaller is not the current caller *only* log a warning
if (!previousCaller.equals(caller)) { if (!previousCaller.equals(caller)) {
log log.warn(LogManager
.warn(LogManager
.getHeader( .getHeader(
this, this,
"restore_auth_sys_state", "restore_auth_sys_state",
@@ -741,7 +738,7 @@ public class Context implements AutoCloseable {
dbConnection.setConnectionMode(false, false); dbConnection.setConnectionMode(false, false);
break; break;
default: default:
log.warn("New context mode detected that has nog been configured."); log.warn("New context mode detected that has not been configured.");
break; break;
} }
} catch (SQLException ex) { } catch (SQLException ex) {
@@ -803,7 +800,7 @@ public class Context implements AutoCloseable {
* entity. This means changes to the entity will be tracked and persisted to the database. * entity. This means changes to the entity will be tracked and persisted to the database.
* *
* @param entity The entity to reload * @param entity The entity to reload
* @param <E> The class of the enity. The entity must implement the {@link ReloadableEntity} interface. * @param <E> The class of the entity. The entity must implement the {@link ReloadableEntity} interface.
* @return A (possibly) <b>NEW</b> reference to the entity that should be used for further processing. * @return A (possibly) <b>NEW</b> reference to the entity that should be used for further processing.
* @throws SQLException When reloading the entity from the database fails. * @throws SQLException When reloading the entity from the database fails.
*/ */
@@ -816,7 +813,7 @@ public class Context implements AutoCloseable {
* Remove an entity from the cache. This is necessary when batch processing a large number of items. * Remove an entity from the cache. This is necessary when batch processing a large number of items.
* *
* @param entity The entity to reload * @param entity The entity to reload
* @param <E> The class of the enity. The entity must implement the {@link ReloadableEntity} interface. * @param <E> The class of the entity. The entity must implement the {@link ReloadableEntity} interface.
* @throws SQLException When reloading the entity from the database fails. * @throws SQLException When reloading the entity from the database fails.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@@ -17,6 +17,7 @@ import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.rmi.dgc.VMID; import java.rmi.dgc.VMID;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@@ -33,7 +34,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.coverity.security.Escape; import com.coverity.security.Escape;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringSubstitutor; import org.apache.commons.text.StringSubstitutor;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;

View File

@@ -15,7 +15,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -23,7 +22,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet; import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
/** /**
* This class represents a query which the discovery backend can use * This class represents a query which the discovery back-end can use.
* *
* @author Kevin Van de Velde (kevin at atmire dot com) * @author Kevin Van de Velde (kevin at atmire dot com)
*/ */
@@ -273,7 +272,7 @@ public class DiscoverQuery {
/** /**
* Sets the fields which you want Discovery to return in the search results. * Sets the fields which you want Discovery to return in the search results.
* It is HIGHLY recommended to limit the fields returned, as by default * It is HIGHLY recommended to limit the fields returned, as by default
* some backends (like Solr) will return everything. * some back-ends (like Solr) will return everything.
* *
* @param field field to add to the list of fields returned * @param field field to add to the list of fields returned
*/ */

View File

@@ -9,7 +9,6 @@ package org.dspace.eperson.dao.impl;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;

View File

@@ -10,6 +10,7 @@ package org.dspace.statistics;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
@@ -18,13 +19,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import au.com.bytecode.opencsv.CSVWriter; import au.com.bytecode.opencsv.CSVWriter;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
/** /**
* @author kevinvandevelde at atmire.com * @author kevinvandevelde at atmire.com
* Date: 21-jan-2009 * Date: 21-Jan-2009
* Time: 13:44:48 * Time: 13:44:48
*/ */
public class Dataset { public class Dataset {