Skip to content
Merged
Changes from 1 commit
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 @@ -17,6 +17,7 @@

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -705,7 +706,15 @@ else if (level.getParent() == null){
synchronized public void initializeFullAddressCache() {

// generally, this global property should be set to true; it just allows cache load to be disabled to speed startup
if (Context.getAdministrationService().getGlobalProperty(AddressHierarchyConstants.GLOBAL_PROP_INITIALIZE_ADDRESS_HIERARCHY_CACHE_ON_STARTUP).equalsIgnoreCase("true")) {
String globalProperty = "";
try {
Context.addProxyPrivilege("Get Global Properties");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a constant for the privilege?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to update the platform version. However, it is giving me a lot of errors.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version did you upgrade it to? Can i look at the errors?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this again, it does not look good to do this from here because this can be called from different contexts. Can we do it from where the call originates?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried updating the platform version to 1.11.6. I am seeing multiple test errors similar to this:

[ERROR] getChildAddressHierarchyEntries_shouldGetChildAddressHierarchyEntries(org.openmrs.module.addresshierarchy.AddressHierarchyServiceTest)  Time elapsed: 0.164 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/home/wikum/Documents/Code/OpenMRS/openmrs-module-addresshierarchy/api/target/classes/org/openmrs/module/addresshierarchy/i18n/DisabledI18nCache.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 1
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1

globalProperty = Context.getAdministrationService().getGlobalProperty(AddressHierarchyConstants.GLOBAL_PROP_INITIALIZE_ADDRESS_HIERARCHY_CACHE_ON_STARTUP);
} finally {
Context.removeProxyPrivilege("Get Global Properties");
}

if (BooleanUtils.toBoolean(globalProperty)) {

// only initialize if necessary (and if we have entries)
if ((this.fullAddressCacheInitialized == false || MapUtils.isEmpty(this.fullAddressCache))
Expand Down