Skip to content

Commit

Permalink
LPS-59076 OSGI components should not call *ServiceUtil class
Browse files Browse the repository at this point in the history
  • Loading branch information
hhuijser authored and brianchandotcom committed Oct 7, 2015
1 parent 4e49016 commit 08e2b75
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.properties
Expand Up @@ -248,6 +248,7 @@
## Source Formatter
##

source.formatter.check.modules.service.util=false
source.formatter.check.unprocessed.exceptions=false

##
Expand Down
Expand Up @@ -911,6 +911,17 @@ else if (absolutePath.contains("/test/unit/") &&
"ResourceBundle.getBundle: " + fileName);
}

// LPS-59076

if (_checkModulesServiceUtil && isModulesFile(absolutePath) &&
newContent.contains("@Component") &&
newContent.contains("ServiceUtil.")) {

processErrorMessage(
fileName,
"OSGI Component should not call ServiceUtil: " + fileName);
}

newContent = getCombinedLinesContent(
newContent, _combinedLinesPattern1);
newContent = getCombinedLinesContent(
Expand Down Expand Up @@ -949,6 +960,9 @@ protected List<String> doGetFileNames() throws Exception {
if (portalSource) {
fileNames = getPortalJavaFiles();

_checkModulesServiceUtil = GetterUtil.getBoolean(
System.getProperty(
"source.formatter.check.modules.service.util"));
_checkUnprocessedExceptions = GetterUtil.getBoolean(
System.getProperty(
"source.formatter.check.unprocessed.exceptions"));
Expand Down Expand Up @@ -3221,6 +3235,7 @@ protected String sortExceptions(String line) {
private Pattern _catchExceptionPattern = Pattern.compile(
"\n(\t+)catch \\((.+Exception) (.+)\\) \\{\n");
private List<String> _checkJavaFieldTypesExclusionFiles;
private boolean _checkModulesServiceUtil;
private boolean _checkUnprocessedExceptions;
private Pattern _combinedLinesPattern1 = Pattern.compile(
"\n(\t*).+(=|\\]) (\\{)\n");
Expand Down
1 change: 1 addition & 0 deletions portal-impl/build.xml
Expand Up @@ -1001,6 +1001,7 @@ svn://svn.liferay.com/repos/public/alloy/trunk/sandbox/taglibs.
>
<jvmarg value="-Xmx512m" />
<jvmarg value="-Xss2048k" />
<jvmarg value="-Dsource.formatter.check.modules.service.util=${source.formatter.check.modules.service.util}" />
<jvmarg value="-Dsource.formatter.check.unprocessed.exceptions=${source.formatter.check.unprocessed.exceptions}" />
<jvmarg value="-Dsource.formatter.excludes=${source.formatter.excludes}" />
<arg value="format.current.branch=${format.current.branch}" />
Expand Down

0 comments on commit 08e2b75

Please sign in to comment.