Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I stop spring from injecting Properties.class into my plugin?

We have a plugin that worked fine on Jira 7 but began failing to start on Jira 8.  I narrowed down the failure to a class that has a Properties.class being injected into it by Jira; presumably, by the Spring framework.  This application is designed to be agnostic of Jira and operate in a number of our tools.  For that reason, it does not import anything specific to Jira or any other tool.  It does not import the Spring framework, but still receives the false class being injected into it.

The usual way this class gets initialized is through it's own no-arg constructor, which calls private methods to send a Properties file that has been read off the file system, into a constructor which accepts the Properties file.

Roughly, the class is (It's the properties file in the second constructor that is being injected):

public ConfigClass() {
    this(buildPropertiesFile());
}

public ConfigClass(Properties config) {
    fieldVar1 = config.getProperty("blah");
    etc...
}

Is it possible to stop the Properties file from being injected without having to import the spring framework?

It's written this way for improved test-ability, which I'm trying to preserve.  I've confirmed it works if I get rid of the constructor accepting the Properties.class and just initialize fully through the no-arg constructor, but this breaks most of it's tests because we then can't mock out the incoming properties.  At least not cleanly.

0 comments

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira

Announcement: New Issue Create modal will be available to all customers starting 6th December 2021

Greetings Everyone!   I’m Arjoon, a PM in Jira Cloud. Earlier this year, we shared our current efforts to improve the Issue Create experience in Jira. One of the key improvements that we hav...

178 views 1 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you