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

Misc. improvements #58

Open
wants to merge 27 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f2b7905
Replace use of obsolete Vector collection
dtrebbien Oct 14, 2017
f8dbd9b
Use String.contains()
dtrebbien Oct 14, 2017
8d555ac
Remove unused variable assignments
dtrebbien Oct 14, 2017
29f5ccc
Use isEmpty() to check whether a collection is (or isn't) empty
dtrebbien Oct 14, 2017
c122cc7
Correct typos
dtrebbien Oct 14, 2017
2ca8527
Supply type information
dtrebbien Oct 14, 2017
39ff25f
Use enhanced for loops
dtrebbien Oct 14, 2017
fecd057
Use StringBuilder rather than StringBuffer if synchronization is unne…
dtrebbien Oct 14, 2017
7a3482d
Remove unnecessary boxing/unboxing
dtrebbien Oct 14, 2017
11d38b5
LoggingPrintStream.println() should atomically access/modify its buffer
dtrebbien Oct 14, 2017
e841984
Correct potentially confusing whitespace indentation
dtrebbien Oct 14, 2017
8f801da
Use Collections.emptyMap() rather than EMPTY_MAP
dtrebbien Oct 14, 2017
282ddff
Delete unused imports
dtrebbien Oct 14, 2017
cb5a9c6
Guard against integer overflow
dtrebbien Oct 14, 2017
4a84ab4
LogPrintWriter.println() should atomically access/modify the buffer
dtrebbien Oct 14, 2017
081e61b
Fields storing cached values should be marked transient
dtrebbien Oct 14, 2017
40bbb75
Improve indentation
dtrebbien Oct 15, 2017
7fba6ba
Simplify ChildNodeAttic.remove(NodeEntry)
dtrebbien Oct 15, 2017
571b82e
Use addAll(Arrays.asList(...)) to add each array element
dtrebbien Oct 15, 2017
65069d0
Utilize Commons Lang StrBuilder
dtrebbien Oct 15, 2017
b16be2e
Use StringUtils' null-safe equals() and endsWith()
dtrebbien Oct 15, 2017
cd2217d
Don't recompute name.indexOf('[')
dtrebbien Oct 15, 2017
748fc81
Supply type information
dtrebbien Oct 15, 2017
8aa798c
Synchronize access to listenerMap
dtrebbien Oct 15, 2017
bb4e864
Fix a NPE if callback is null
dtrebbien Oct 15, 2017
778a8f5
Supply type information
dtrebbien Oct 15, 2017
6090c5f
Remove unnecessary boxing/unboxing
dtrebbien Oct 15, 2017
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
13,430 changes: 13,430 additions & 0 deletions changes.patch

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private Utils() {
public static AmazonS3Client openService(final Properties prop) {
String accessKey = prop.getProperty(S3Constants.ACCESS_KEY);
String secretKey = prop.getProperty(S3Constants.SECRET_KEY);
AmazonS3Client s3service = null;
AmazonS3Client s3service;
if (StringUtils.isNullOrEmpty(accessKey)
|| StringUtils.isNullOrEmpty(secretKey)) {
LOG.info("Configuring Amazon Client from environment");
Expand All @@ -95,7 +95,7 @@ public static AmazonS3Client openService(final Properties prop) {
getClientConfiguration(prop));
}
String region = prop.getProperty(S3Constants.S3_REGION);
String endpoint = null;
String endpoint;
String propEndPoint = prop.getProperty(S3Constants.S3_END_POINT);
if ((propEndPoint != null) && !"".equals(propEndPoint)) {
endpoint = propEndPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public boolean exists(DataIdentifier identifier, boolean touch)
throws DataStoreException {
long start = System.currentTimeMillis();
String key = getKeyName(identifier);
ObjectMetadata objectMetaData = null;
ObjectMetadata objectMetaData;
boolean retVal = false;
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Expand Down Expand Up @@ -313,12 +313,11 @@ public boolean exists(DataIdentifier identifier, boolean touch)
public void touchAsync(final DataIdentifier identifier,
final long minModifiedDate, final AsyncTouchCallback callback)
throws DataStoreException {
if (callback == null) {
throw new IllegalArgumentException("callback parameter cannot be null in touchAsync");
}
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
if (callback == null) {
throw new IllegalArgumentException(
"callback parameter cannot be null in touchAsync");
}
Thread.currentThread().setContextClassLoader(
getClass().getClassLoader());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testDataMigration() {
assertRecord(data, rec);

randomGen.nextBytes(data);
rec = s3ds.addRecord(new ByteArrayInputStream(data));
s3ds.addRecord(new ByteArrayInputStream(data));
s3ds.close();

} catch (Exception e) {
Expand Down
4 changes: 4 additions & 0 deletions jackrabbit-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ org.apache.jackrabbit.test.api.query.qom.NodeLocalNameTest#testURILiteral
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ public void itemDestroyed(ItemId id, ItemData data) {
*/
public synchronized String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ItemManager (" + super.toString() + ")\n");
builder.append("ItemManager (").append(super.toString()).append(")\n");
builder.append("Items in cache:\n");
synchronized (itemCache) {
for (ItemId id : itemCache.keySet()) {
Expand All @@ -1062,7 +1062,7 @@ public synchronized String toString() {
} else {
builder.append(" ");
}
builder.append(id + "\t" + safeGetJCRPath(id) + " (" + item + ")\n");
builder.append(id).append('\t').append(safeGetJCRPath(id)).append(" (").append(item).append(")\n");
}
}
return builder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Object perform(SessionContext context) throws RepositoryException {
context.getSessionImpl().logout();
throw e;
}
if (dirty.size() == 0) {
if (dirty.isEmpty()) {
// no transient items, nothing to do here
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private void resizeAll() {
synchronized (caches) {
list.addAll(caches.keySet());
}
if (list.size() == 0) {
if (list.isEmpty()) {
// nothing to do
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ public void close() throws IOException {
conHelper.exec(updateDataSQL,
new Object[]{
new StreamWrapper(in, length),
new Long(System.currentTimeMillis()),
new Long(length),
System.currentTimeMillis(),
length,
parentDir,
name
});
Expand All @@ -743,8 +743,8 @@ public void close() throws IOException {
parentDir,
name,
new StreamWrapper(in, length),
new Long(System.currentTimeMillis()),
new Long(length)
System.currentTimeMillis(),
length
});
}
}
Expand Down Expand Up @@ -921,7 +921,7 @@ protected void createDeepFolder(String folderPath)
new Object[]{
parentDir,
name,
new Long(System.currentTimeMillis())});
System.currentTimeMillis()});
} catch (SQLException e) {
String msg = "failed to create folder entry: " + folderPath;
log.error(msg, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,36 +283,36 @@ public Name[] getAllNodeTypes() {
}

public QItemDefinition[] getAllItemDefs() {
if (namedItemDefs.size() == 0 && unnamedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty() && unnamedItemDefs.isEmpty()) {
return QItemDefinition.EMPTY_ARRAY;
}
ArrayList<QItemDefinition> defs = new ArrayList<QItemDefinition>(namedItemDefs.size() + unnamedItemDefs.size());
for (List<QItemDefinition> itemDefs : namedItemDefs.values()) {
defs.addAll(itemDefs);
}
defs.addAll(unnamedItemDefs);
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QItemDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QItemDefinition[defs.size()]);
}

public QItemDefinition[] getNamedItemDefs() {
if (namedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty()) {
return QItemDefinition.EMPTY_ARRAY;
}
ArrayList<QItemDefinition> defs = new ArrayList<QItemDefinition>(namedItemDefs.size());
for (List<QItemDefinition> itemDefs : namedItemDefs.values()) {
defs.addAll(itemDefs);
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QItemDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QItemDefinition[defs.size()]);
}

public QItemDefinition[] getUnnamedItemDefs() {
if (unnamedItemDefs.size() == 0) {
if (unnamedItemDefs.isEmpty()) {
return QItemDefinition.EMPTY_ARRAY;
}
return unnamedItemDefs.toArray(new QItemDefinition[unnamedItemDefs.size()]);
Expand All @@ -324,14 +324,14 @@ public boolean hasNamedItemDef(Name name) {

public QItemDefinition[] getNamedItemDefs(Name name) {
List<QItemDefinition> defs = namedItemDefs.get(name);
if (defs == null || defs.size() == 0) {
if (defs == null || defs.isEmpty()) {
return QItemDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QItemDefinition[defs.size()]);
}

public QNodeDefinition[] getAllNodeDefs() {
if (namedItemDefs.size() == 0 && unnamedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty() && unnamedItemDefs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size() + unnamedItemDefs.size());
Expand All @@ -347,14 +347,14 @@ public QNodeDefinition[] getAllNodeDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QNodeDefinition[defs.size()]);
}

public QNodeDefinition[] getNamedNodeDefs() {
if (namedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size());
Expand All @@ -365,15 +365,15 @@ public QNodeDefinition[] getNamedNodeDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QNodeDefinition[defs.size()]);
}

public QNodeDefinition[] getNamedNodeDefs(Name name) {
List<QItemDefinition> list = namedItemDefs.get(name);
if (list == null || list.size() == 0) {
if (list == null || list.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(list.size());
Expand All @@ -382,14 +382,14 @@ public QNodeDefinition[] getNamedNodeDefs(Name name) {
defs.add((QNodeDefinition) def);
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QNodeDefinition[defs.size()]);
}

public QNodeDefinition[] getUnnamedNodeDefs() {
if (unnamedItemDefs.size() == 0) {
if (unnamedItemDefs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(unnamedItemDefs.size());
Expand All @@ -398,7 +398,7 @@ public QNodeDefinition[] getUnnamedNodeDefs() {
defs.add((QNodeDefinition) def);
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QNodeDefinition[defs.size()]);
Expand All @@ -407,7 +407,7 @@ public QNodeDefinition[] getUnnamedNodeDefs() {
public QNodeDefinition[] getAutoCreateNodeDefs() {
// since auto-create items must have a name,
// we're only searching the named item definitions
if (namedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size());
Expand All @@ -418,14 +418,14 @@ public QNodeDefinition[] getAutoCreateNodeDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QNodeDefinition[defs.size()]);
}

public QPropertyDefinition[] getAllPropDefs() {
if (namedItemDefs.size() == 0 && unnamedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty() && unnamedItemDefs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size() + unnamedItemDefs.size());
Expand All @@ -441,14 +441,14 @@ public QPropertyDefinition[] getAllPropDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QPropertyDefinition[defs.size()]);
}

public QPropertyDefinition[] getNamedPropDefs() {
if (namedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size());
Expand All @@ -459,15 +459,15 @@ public QPropertyDefinition[] getNamedPropDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QPropertyDefinition[defs.size()]);
}

public QPropertyDefinition[] getNamedPropDefs(Name name) {
List<QItemDefinition> list = namedItemDefs.get(name);
if (list == null || list.size() == 0) {
if (list == null || list.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(list.size());
Expand All @@ -476,14 +476,14 @@ public QPropertyDefinition[] getNamedPropDefs(Name name) {
defs.add((QPropertyDefinition) def);
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QPropertyDefinition[defs.size()]);
}

public QPropertyDefinition[] getUnnamedPropDefs() {
if (unnamedItemDefs.size() == 0) {
if (unnamedItemDefs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(unnamedItemDefs.size());
Expand All @@ -492,7 +492,7 @@ public QPropertyDefinition[] getUnnamedPropDefs() {
defs.add((QPropertyDefinition) def);
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QPropertyDefinition[defs.size()]);
Expand All @@ -501,7 +501,7 @@ public QPropertyDefinition[] getUnnamedPropDefs() {
public QPropertyDefinition[] getAutoCreatePropDefs() {
// since auto-create items must have a name,
// we're only searching the named item definitions
if (namedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size());
Expand All @@ -512,7 +512,7 @@ public QPropertyDefinition[] getAutoCreatePropDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QPropertyDefinition[defs.size()]);
Expand All @@ -521,7 +521,7 @@ public QPropertyDefinition[] getAutoCreatePropDefs() {
public QPropertyDefinition[] getMandatoryPropDefs() {
// since mandatory items must have a name,
// we're only searching the named item definitions
if (namedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
ArrayList<QPropertyDefinition> defs = new ArrayList<QPropertyDefinition>(namedItemDefs.size());
Expand All @@ -532,7 +532,7 @@ public QPropertyDefinition[] getMandatoryPropDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QPropertyDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QPropertyDefinition[defs.size()]);
Expand All @@ -541,7 +541,7 @@ public QPropertyDefinition[] getMandatoryPropDefs() {
public QNodeDefinition[] getMandatoryNodeDefs() {
// since mandatory items must have a name,
// we're only searching the named item definitions
if (namedItemDefs.size() == 0) {
if (namedItemDefs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
ArrayList<QNodeDefinition> defs = new ArrayList<QNodeDefinition>(namedItemDefs.size());
Expand All @@ -552,7 +552,7 @@ public QNodeDefinition[] getMandatoryNodeDefs() {
}
}
}
if (defs.size() == 0) {
if (defs.isEmpty()) {
return QNodeDefinition.EMPTY_ARRAY;
}
return defs.toArray(new QNodeDefinition[defs.size()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public String getExcerpt(NodeId id, int maxFragments, int maxFragmentSize)
exProvider.init(query, index);
return exProvider.getExcerpt(id, maxFragments, maxFragmentSize);
}
StringBuffer text = new StringBuffer();
StringBuilder text = new StringBuilder();
String separator = "";
for (int i = 0; i < fields.length; i++) {
if (fields[i].stringValue().length() == 0) {
Expand Down
Loading