Skip to content

Commit

Permalink
JDO-823: Fix more sonarcloud issues of type Code Smells (#68)
Browse files Browse the repository at this point in the history
* JDO-823: Attributes deprecated in HTML 5 should not be used

* JDO-823: Synchronized classes StringBuffer and Hashtable should not be used

* JDO-823: @OverRide should be used on verriding methods

* JDO-823: Fixed formatting

* JDO-823: Fields in a Serializable class should either be transient or serilizable
  • Loading branch information
mboapache authored Feb 2, 2023
1 parent 5271b91 commit 38c7968
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/javax/jdo/JDOException.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class JDOException extends java.lang.RuntimeException {
*
* @serial the failed <code>Object</code>
*/
Object failed;
transient Object failed;

/** The Internationalization message helper. */
private static final I18NHelper MSG = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N
Expand Down Expand Up @@ -195,7 +195,7 @@ public synchronized Throwable initCause(Throwable cause) {
public synchronized String toString() {
int len = nested == null ? 0 : nested.length;
// calculate approximate size of the String to return
StringBuffer sb = new StringBuffer(10 + 100 * len);
StringBuilder sb = new StringBuilder(10 + 100 * len);
sb.append(super.toString());
// include failed object information
if (failed != null) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/javax/jdo/datastore/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<body>
This package contains the JDO specification datastore interfaces.
</body>
</html>
2 changes: 1 addition & 1 deletion api/src/main/java/javax/jdo/identity/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<body>
This package contains the JDO specification identity interfaces and classes.
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class InstanceLifecycleEvent extends java.util.EventObject {
private final int eventType;

/** The "other" object associated with the event. */
private final Object target;
private final transient Object target;

/**
* Creates a new event object with the specified <code>source</code> and <code>type</code>.
Expand Down Expand Up @@ -107,6 +107,7 @@ public int getEventType() {
* @see #getDetachedInstance()
* @see "Section 12.15, Java Data Objects 2.0 Specification"
*/
@Override
public Object getSource() {
return super.getSource();
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/javax/jdo/listener/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<body>
This package contains the JDO specification listener interfaces and classes.
<P>There are two kinds of interfaces defined to allow an application to
manage life cycle changes to persistent objects.
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/javax/jdo/metadata/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<body>
This package contains classes representing the different components of the JDO Metadata.
It mirrors the structure of the XML schema.
</body>
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/javax/jdo/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<body>
This package contains the JDO specification interfaces and classes.
<P>There are two major objectives of the JDO architecture:
first, to provide application programmers a transparent,
Expand Down
7 changes: 4 additions & 3 deletions api/src/main/java/javax/jdo/spi/I18NHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import java.lang.reflect.InvocationTargetException;
import java.security.PrivilegedAction;
import java.text.MessageFormat;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import javax.jdo.JDOFatalInternalException;
import javax.jdo.LegacyJava;
Expand Down Expand Up @@ -50,10 +51,10 @@
public class I18NHelper {

/** Bundles that have already been loaded */
private static final Hashtable<String, ResourceBundle> bundles = new Hashtable<>();
private static final Map<String, ResourceBundle> bundles = new HashMap<>();

/** Helper instances that have already been created */
private static final Hashtable<String, I18NHelper> helpers = new Hashtable<>();
private static final Map<String, I18NHelper> helpers = new HashMap<>();

/** The default locale for this VM. */
private static final Locale locale = Locale.getDefault();
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/javax/jdo/spi/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<body>
<P>This package contains the interfaces and classes used by JDO implementations.
<P>JDO defines interfaces and classes to be used by application programmers
when using classes whose instances are to be stored in persistent storage
Expand Down
2 changes: 1 addition & 1 deletion exectck/src/main/java/org/apache/jdo/exectck/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Help extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

StringBuffer msg = new StringBuffer();
StringBuilder msg = new StringBuilder();

msg.append("\n\n*** jdo-exectck Maven plugin ***\n\n");
msg.append("This plugin executes the JDO Technology Compatibility Kit (TCK)\n");
Expand Down
2 changes: 1 addition & 1 deletion exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
runonce = (runonce == null) ? "false" : runonce;

// Add Mapping and schemaname to properties file
StringBuffer propsFileData = new StringBuffer();
StringBuilder propsFileData = new StringBuilder();
propsFileData.append("\n### Properties below added by maven 2 goal RunTCK.jdori");
propsFileData.append("\njavax.jdo.mapping.Schema=" + idtype + mapping);
mapping = (mapping.equals("0")) ? "" : mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void printClasspath() {
static String readFile(String fileName) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String line = null;
StringBuffer stringBuf = new StringBuffer();
StringBuilder stringBuf = new StringBuilder();
String ls = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
stringBuf.append(line);
Expand Down

0 comments on commit 38c7968

Please sign in to comment.