Skip to content

Commit

Permalink
Fix PMD:AvoidUncheckedExceptionsInSignatures (logger)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo committed Jul 11, 2022
1 parent 89a3fcc commit c6504da
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
Expand Up @@ -64,7 +64,7 @@ public class FileLogHandler extends LogHandler {
* @throws IllegalArgumentException if one or more property values are invalid. All valid properties will still be set.
*/
@Override
public void configure(Properties props, String prefix) throws IllegalArgumentException {
public void configure(Properties props, String prefix) {

String value = null;
String property = null;
Expand Down
Expand Up @@ -80,8 +80,10 @@ public void acceptAllLevels() {
*
* "NOFORCE" specifies that FORCE messages should not be sent to this handler; any that are sent to this handler will be
* ignored. You should typically use this in conjunction with a list of log levels that are accepted.
*
* @throws IllegalArgumentException
*/
protected void setLevels(String levelList) throws IllegalArgumentException {
protected void setLevels(String levelList) {

String s;
levels = 0;
Expand Down Expand Up @@ -141,7 +143,8 @@ public void flush() {
// No-op
}

abstract public void configure(Properties props, String prefix) throws IllegalArgumentException;
/** @throws IllegalArgumentException */
abstract public void configure(Properties props, String prefix);

/**
* Publish string to log
Expand Down
Expand Up @@ -155,8 +155,10 @@ public String[] getUpdateableProperties() {

/**
* Dynamically update a property.
*
* @throws IllegalArgumentException
*/
public synchronized void updateProperty(String name, String value) throws IllegalArgumentException {
public synchronized void updateProperty(String name, String value) {

if (name == null || value == null || value.equals("")) {
return;
Expand Down Expand Up @@ -646,8 +648,10 @@ private String[] parseClassNames(String classNamePropertyValue) {
* Convert a string representation of a log level to its integer value.
*
* @param levelStr Log level string. One of: ERROR, WARNING, INFO, DEBUG DEBUGMED, DEBUGHIGH
*
* @throws IllegalArgumentException
*/
public static int levelStrToInt(String levelStr) throws IllegalArgumentException {
public static int levelStrToInt(String levelStr) {

if (levelStr.equals("FORCE")) {
return Logger.FORCE;
Expand All @@ -674,8 +678,10 @@ public static int levelStrToInt(String levelStr) throws IllegalArgumentException
* Convert an int representation of a log level to its string value.
*
* @param level Log level int. One of: ERROR, WARNING, INFO, DEBUG DEBUGMED, DEBUGHIGH
*
* @throws IllegalArgumentException
*/
public static String levelIntToStr(int level) throws IllegalArgumentException {
public static String levelIntToStr(int level) {

switch (level) {
case FORCE:
Expand All @@ -702,8 +708,10 @@ public static String levelIntToStr(int level) throws IllegalArgumentException {
* Convert an JUL int representation of a log level to its string value.
*
* @param level Log level int. One of:ALL,FORCE,SEVERE,WARNING,INFO,CONFIG,FINE,FINER,FINEST, OFF
*
* @throws IllegalArgumentException
*/
public static String jullevelIntToStr(int level) throws IllegalArgumentException {
public static String jullevelIntToStr(int level) {

if (level == Level.ALL.intValue()) {
return Level.ALL.getName();
Expand Down Expand Up @@ -735,8 +743,10 @@ public static String jullevelIntToStr(int level) throws IllegalArgumentException
* Convert an int representation of a log level to its equivalent java.util.logging.LogLevel.
*
* @param level Log level int. One of: ERROR, WARNING, INFO, DEBUG DEBUGMED, DEBUGHIGH
*
* @throws IllegalArgumentException
*/
public static Level levelIntToJULLevel(int level) throws IllegalArgumentException {
public static Level levelIntToJULLevel(int level) {

switch (level) {
case FORCE:
Expand Down Expand Up @@ -766,8 +776,10 @@ public static Level levelIntToJULLevel(int level) throws IllegalArgumentExceptio
* Convert an java.util.logging.LogLevel representation of a log level to its equivalent int value.
*
* @param level Log level int. One of: ERROR, WARNING, INFO, DEBUG DEBUGMED, DEBUGHIGH
*
* @throws IllegalArgumentException
*/
public static int levelJULLevelToInt(Level level) throws IllegalArgumentException {
public static int levelJULLevelToInt(Level level) {

if (level.equals(EMERGENCY)) {
return FORCE; // TODO: Need to wait for nucleus team to add custom log level
Expand Down
Expand Up @@ -47,7 +47,7 @@ public class StreamLogHandler extends LogHandler {
* @throws IllegalArgumentException if one or more property values are invalid. All valid properties will still be set.
*/
@Override
public void configure(Properties props, String prefix) throws IllegalArgumentException {
public void configure(Properties props, String prefix) {

String value = null;
String property = null;
Expand Down
Expand Up @@ -129,8 +129,7 @@ public static void setFacility(int f) {
* @throws IllegalArgumentException if one or more property values are invalid. All valid properties will still be set.
* @throws UnsatisfiedLinkError if native code can't be loaded
*/
public void configure(String facilityStr, String logpidStr, String logconsoleStr, String identityStr, String outputStr)
throws IllegalArgumentException, UnsatisfiedLinkError {
public void configure(String facilityStr, String logpidStr, String logconsoleStr, String identityStr, String outputStr) {

// LogManager lm = LogManager.getLogManager();

Expand Down

0 comments on commit c6504da

Please sign in to comment.