Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thread safety issues by not using singletons for generators #415

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -57,7 +56,6 @@
* Generate a basic conversion class between two versions of a model.
*/
@Named("converters")
@Singleton
public class ConverterGenerator extends AbstractJavaModelloGenerator {
public void generate(Model model, Properties parameters) throws ModelloException {
initialize(model, parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -53,7 +52,6 @@
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
@Named("dom4j-reader")
@Singleton
public class Dom4jReaderGenerator extends AbstractXmlJavaGenerator {

private boolean requiresDomSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -56,7 +55,6 @@
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
@Named("dom4j-writer")
@Singleton
public class Dom4jWriterGenerator extends AbstractXmlJavaGenerator {

private boolean requiresDomSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -55,7 +54,6 @@
* @author <a href="mailto:[email protected]">Simone Tripodi</a>
*/
@Named("jackson-reader")
@Singleton
public class JacksonReaderGenerator extends AbstractJacksonGenerator {

private static final String SOURCE_PARAM = "source";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand All @@ -50,7 +49,6 @@
* @author <a href="mailto:[email protected]">Simone Tripodi</a>
*/
@Named("jackson-writer")
@Singleton
public class JacksonWriterGenerator extends AbstractJacksonGenerator {

private boolean requiresDomSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.io.Serializable;
Expand Down Expand Up @@ -69,7 +68,6 @@
* @author <a href="mailto:[email protected]">Jason van Zyl</a>
*/
@Named("java")
@Singleton
public class JavaModelloGenerator extends AbstractJavaModelloGenerator {

private Collection<String> immutableTypes = new HashSet<String>(Arrays.asList(new String[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.codehaus.modello.plugin.jdom;

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -48,7 +47,6 @@
* @author [email protected]
*/
@Named("jdom-writer")
@Singleton
public class JDOMWriterGenerator extends AbstractJDOMGenerator {

private boolean requiresDomSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -52,7 +51,6 @@
* @since 1.8
*/
@Named("jsonschema")
@Singleton
public final class JsonSchemaGenerator extends AbstractXmlJavaGenerator {

public void generate(Model model, Properties parameters) throws ModelloException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -55,7 +54,6 @@
* @author <a href="mailto:[email protected]">Simone Tripodi</a>
*/
@Named("sax-writer")
@Singleton
public class SaxWriterGenerator extends AbstractXmlJavaGenerator {

private boolean requiresDomSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import org.codehaus.modello.model.ModelClass;

Expand All @@ -33,7 +32,6 @@
* @author <a href="mailto:[email protected]">Simone Tripodi</a>
*/
@Named("snakeyaml-extended-reader")
@Singleton
public class SnakeYamlExtendedReaderGenerator extends SnakeYamlReaderGenerator {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -53,7 +52,6 @@
* @author <a href="mailto:[email protected]">Simone Tripodi</a>
*/
@Named("snakeyaml-reader")
@Singleton
public class SnakeYamlReaderGenerator extends AbstractSnakeYamlGenerator {

private static final String SOURCE_PARAM = "source";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand All @@ -50,7 +49,6 @@
* @author <a href="mailto:[email protected]">Simone Tripodi</a>
*/
@Named("snakeyaml-writer")
@Singleton
public class SnakeYamlWriterGenerator extends AbstractSnakeYamlGenerator {

public void generate(Model model, Properties parameters) throws ModelloException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -58,7 +57,6 @@
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
*/
@Named("stax-reader")
@Singleton
public class StaxReaderGenerator extends AbstractStaxGenerator {

private boolean requiresDomSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -48,7 +47,6 @@
* @author Benjamin Bentmann
*/
@Named("stax-serializer")
@Singleton
public class StaxSerializerGenerator extends AbstractStaxGenerator {

public void generate(Model model, Properties parameters) throws ModelloException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -55,7 +54,6 @@
* @author <a href="mailto:[email protected]">Emmanuel Venisse </a>
*/
@Named("stax-writer")
@Singleton
public class StaxWriterGenerator extends AbstractStaxGenerator {

private boolean requiresDomSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import org.codehaus.modello.model.ModelClass;

Expand All @@ -33,7 +32,6 @@
* @author Benjamin Bentmann
*/
@Named("xpp3-extended-reader")
@Singleton
public class Xpp3ExtendedReaderGenerator extends Xpp3ReaderGenerator {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import org.codehaus.modello.plugin.java.javasource.JClass;
import org.codehaus.modello.plugin.java.javasource.JField;
Expand All @@ -39,7 +38,6 @@
* @since 1.10
*/
@Named("xpp3-extended-writer")
@Singleton
public class Xpp3ExtendedWriterGenerator extends Xpp3WriterGenerator {
@Override
protected boolean isLocationTracking() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -58,7 +57,6 @@
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
*/
@Named("xpp3-reader")
@Singleton
public class Xpp3ReaderGenerator extends AbstractXpp3Generator {

private static final String SOURCE_PARAM = "source";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -54,7 +53,6 @@
* @author <a href="mailto:[email protected]">Emmanuel Venisse </a>
*/
@Named("xpp3-writer")
@Singleton
public class Xpp3WriterGenerator extends AbstractXpp3Generator {
private String extendedClassnameSuffix;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -52,7 +51,6 @@
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
@Named("xsd")
@Singleton
public class XsdGenerator extends AbstractXmlGenerator {
/**
* Value standing for any element name (used on xml.tagName)
Expand Down