Every D Ranked bug is fixed.

This commit is contained in:
Angel Borroy
2019-08-26 16:37:51 +02:00
parent 81a4717c51
commit fed32bdf73
14 changed files with 107 additions and 85 deletions
@@ -951,7 +951,7 @@ public class AlfrescoCoreAdminHandler extends CoreAdminHandler
{ {
if (maxNodeId >= midpoint) if (maxNodeId >= midpoint)
{ {
if(density >= 1) if(density >= 1 || density == 0)
{ {
//This is fully dense shard. I'm not sure if it's possible to have more nodes on the shards //This is fully dense shard. I'm not sure if it's possible to have more nodes on the shards
//then the offset, but if it does happen don't expand. //then the offset, but if it does happen don't expand.
@@ -1195,8 +1195,7 @@ public class AlfrescoSolrDataModel implements QueryConstants
public void removeModel(QName modelQName) public void removeModel(QName modelQName)
{ {
// FIXME: this has no effect. The method should be changed (SEARCH-1482) modelErrors.remove(getM2Model(modelQName).getName());
modelErrors.remove(modelQName);
dictionaryDAO.removeModel(modelQName); dictionaryDAO.removeModel(modelQName);
} }
@@ -957,9 +957,10 @@ public class SolrInformationServer implements InformationServer
SolrIndexSearcher solrIndexSearcher = refCounted.get(); SolrIndexSearcher solrIndexSearcher = refCounted.get();
coreSummary.add("Searcher", solrIndexSearcher.getStatistics()); coreSummary.add("Searcher", solrIndexSearcher.getStatistics());
Map<String, SolrInfoMBean> infoRegistry = core.getInfoRegistry(); Map<String, SolrInfoMBean> infoRegistry = core.getInfoRegistry();
for (String key : infoRegistry.keySet()) for (Entry<String, SolrInfoMBean> infos : infoRegistry.entrySet())
{ {
SolrInfoMBean infoMBean = infoRegistry.get(key); SolrInfoMBean infoMBean = infos.getValue();
String key = infos.getKey();
if (key.equals("/alfresco")) if (key.equals("/alfresco"))
{ {
// TODO Do we really need to fixStats in solr4? // TODO Do we really need to fixStats in solr4?
@@ -2117,8 +2118,9 @@ public class SolrInformationServer implements InformationServer
static void addPropertiesToDoc(Map<QName, PropertyValue> properties, boolean isContentIndexedForNode, static void addPropertiesToDoc(Map<QName, PropertyValue> properties, boolean isContentIndexedForNode,
SolrInputDocument newDoc, SolrInputDocument cachedDoc, boolean transformContentFlag) SolrInputDocument newDoc, SolrInputDocument cachedDoc, boolean transformContentFlag)
{ {
for (QName propertyQName : properties.keySet()) for (Entry<QName, PropertyValue> property : properties.entrySet())
{ {
QName propertyQName = property.getKey();
newDoc.addField(FIELD_PROPERTIES, propertyQName.toString()); newDoc.addField(FIELD_PROPERTIES, propertyQName.toString());
newDoc.addField(FIELD_PROPERTIES, propertyQName.getPrefixString()); newDoc.addField(FIELD_PROPERTIES, propertyQName.getPrefixString());
@@ -3411,12 +3413,17 @@ public class SolrInformationServer implements InformationServer
private void doUpdateDescendantDocs(NodeMetaData parentNodeMetaData, boolean overwrite, private void doUpdateDescendantDocs(NodeMetaData parentNodeMetaData, boolean overwrite,
SolrQueryRequest request, UpdateRequestProcessor processor, LinkedHashSet<Long> stack) SolrQueryRequest request, UpdateRequestProcessor processor, LinkedHashSet<Long> stack)
throws AuthenticationException, IOException, JSONException throws AuthenticationException, IOException, JSONException
{
// skipDescendantDocsForSpecificAspects is initialised on a synchronised method, so access must be also synchronised
synchronized (this)
{ {
if ((skipDescendantDocsForSpecificTypes && typesForSkippingDescendantDocs.contains(parentNodeMetaData.getType())) || if ((skipDescendantDocsForSpecificTypes && typesForSkippingDescendantDocs.contains(parentNodeMetaData.getType())) ||
(skipDescendantDocsForSpecificAspects && shouldBeIgnoredByAnyAspect(parentNodeMetaData.getAspects()))) (skipDescendantDocsForSpecificAspects && shouldBeIgnoredByAnyAspect(parentNodeMetaData.getAspects())))
{ {
return; return;
} }
}
Set<Long> childIds = new HashSet<>(); Set<Long> childIds = new HashSet<>();
@@ -41,6 +41,7 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -472,8 +473,9 @@ public class AsyncBuildSuggestComponent extends SearchComponent implements SolrC
@Override @Override
public long ramBytesUsed() { public long ramBytesUsed() {
long sizeInBytes = 0; long sizeInBytes = 0;
for (String key : suggesters.keySet()) { for (Entry<String, SuggesterCache> suggester : suggesters.entrySet())
sizeInBytes += suggesters.get(key).get(ASYNC_CACHE_KEY).ramBytesUsed(); {
sizeInBytes += suggester.getValue().get(ASYNC_CACHE_KEY).ramBytesUsed();
} }
return sizeInBytes; return sizeInBytes;
} }
@@ -91,7 +91,7 @@ public class RewriteFacetParametersComponent extends SearchComponent
String rows = params.get("rows"); String rows = params.get("rows");
if(rows != null && !rows.isEmpty()) if(rows != null && !rows.isEmpty())
{ {
Integer row = new Integer(rows); Integer row = Integer.valueOf(rows);
// Avoid +1 in SOLR code which produces null:java.lang.NegativeArraySizeException at at org.apache.lucene.util.PriorityQueue.<init>(PriorityQueue.java:56) // Avoid +1 in SOLR code which produces null:java.lang.NegativeArraySizeException at at org.apache.lucene.util.PriorityQueue.<init>(PriorityQueue.java:56)
if(row > 1000000) if(row > 1000000)
{ {
@@ -19,7 +19,6 @@
package org.alfresco.solr.component; package org.alfresco.solr.component;
import java.io.IOException; import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -53,9 +52,9 @@ public class TempFileWarningLogger
log.debug("Looking for temp files matching " + glob + " in directory " + dir); log.debug("Looking for temp files matching " + glob + " in directory " + dir);
} }
try(DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob)) try
{ {
for (Path file : stream) for (Path file : Files.newDirectoryStream(dir, glob))
{ {
if (log.isDebugEnabled()) if (log.isDebugEnabled())
{ {
@@ -74,9 +73,9 @@ public class TempFileWarningLogger
public void removeFiles() public void removeFiles()
{ {
try(DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob)) try
{ {
for (Path file : stream) for (Path file : Files.newDirectoryStream(dir, glob))
{ {
file.toFile().delete(); file.toFile().delete();
} }
@@ -47,7 +47,7 @@ public abstract class AbstractSolrCachingScorer extends Scorer
static { static {
for(int i = 0; i < cache.length; i++) for(int i = 0; i < cache.length; i++)
cache[i] = new Long(i); cache[i] = Long.valueOf(i);
} }
} }
@@ -20,6 +20,7 @@ package org.alfresco.solr.query;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry;
import org.alfresco.solr.AlfrescoSolrDataModel; import org.alfresco.solr.AlfrescoSolrDataModel;
import org.alfresco.solr.AlfrescoSolrDataModel.FieldUse; import org.alfresco.solr.AlfrescoSolrDataModel.FieldUse;
@@ -111,10 +112,9 @@ public class MimetypeGroupingCollector extends DelegatingCollector
rb.rsp.add("analytics", analytics); rb.rsp.add("analytics", analytics);
NamedList<Object> fieldCounts = new NamedList<>(); NamedList<Object> fieldCounts = new NamedList<>();
analytics.add("mimetype()", fieldCounts); analytics.add("mimetype()", fieldCounts);
for(String key : counters.keySet()) for (Entry<String, Counter> counter : counters.entrySet())
{ {
Counter counter = counters.get(key); fieldCounts.add(counter.getKey(), counter.getValue().get());
fieldCounts.add(key, counter.get());
} }
if(this.delegate instanceof DelegatingCollector) { if(this.delegate instanceof DelegatingCollector) {
@@ -3301,12 +3301,9 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
protected String getToken(String field, String value, AnalysisMode analysisMode) throws ParseException protected String getToken(String field, String value, AnalysisMode analysisMode) throws ParseException
{ {
try (TokenStream source = getAnalyzer().tokenStream(field, new StringReader(value)))
{
String tokenised = null;
while (source.incrementToken()) TokenStream source = getAnalyzer().tokenStream(field, new StringReader(value));
{
CharTermAttribute cta = source.getAttribute(CharTermAttribute.class); CharTermAttribute cta = source.getAttribute(CharTermAttribute.class);
OffsetAttribute offsetAtt = source.getAttribute(OffsetAttribute.class); OffsetAttribute offsetAtt = source.getAttribute(OffsetAttribute.class);
TypeAttribute typeAtt = null; TypeAttribute typeAtt = null;
@@ -3331,13 +3328,7 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
token.setPositionIncrement(posIncAtt.getPositionIncrement()); token.setPositionIncrement(posIncAtt.getPositionIncrement());
} }
tokenised = token.toString(); return token.toString();
}
return tokenised;
} catch (IOException e)
{
throw new ParseException("IO" + e.getMessage());
}
} }
@@ -5472,11 +5463,13 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
} }
protected BytesRef analyzeMultitermTerm(String field, String part, Analyzer analyzerIn) { protected BytesRef analyzeMultitermTerm(String field, String part, Analyzer analyzerIn) {
if (analyzerIn == null) analyzerIn = getAnalyzer(); if (analyzerIn == null) analyzerIn = getAnalyzer();
try (TokenStream source = analyzerIn.tokenStream(field, part)) { try
source.reset(); {
TokenStream source = analyzerIn.tokenStream(field, part);
TermToBytesRefAttribute termAtt = source.getAttribute(TermToBytesRefAttribute.class); TermToBytesRefAttribute termAtt = source.getAttribute(TermToBytesRefAttribute.class);
if (!source.incrementToken()) if (!source.incrementToken())
@@ -55,6 +55,13 @@ public class DateQuarterRouter implements DocRouter
calendar.setTime(date); calendar.setTime(date);
int month = calendar.get(Calendar.MONTH); int month = calendar.get(Calendar.MONTH);
int year = calendar.get(Calendar.YEAR); int year = calendar.get(Calendar.YEAR);
return Math.ceil(((year * 12) + (month+1)) / 3) % numShards == shardInstance;
// Avoid using Math.ceil with Integer
int countMonths = ((year * 12) + (month+1));
int grouping = 3;
int ceilGroupInstance = countMonths / grouping + ((countMonths % grouping == 0) ? 0 : 1);
return ceilGroupInstance % numShards == shardInstance;
} }
} }
@@ -280,7 +280,7 @@ public class AlfrescoSolrClusteringComponent extends SearchComponent implements
list.add(doc); list.add(doc);
if (ids != null) { if (ids != null) {
ids.put(doc, new Integer(docid)); ids.put(doc, Integer.valueOf(docid));
} }
} }
return list; return list;
@@ -356,7 +356,7 @@ public class AlfrescoSolrClusteringComponent extends SearchComponent implements
/** /**
* @return Expose for tests. * @return Expose for tests.
*/ */
Map<String, SearchClusteringEngine> getSearchClusteringEngines() { Map<String, SearchClusteringEngine> getSearchClusteringEnginesView() {
return searchClusteringEnginesView; return searchClusteringEnginesView;
} }
@@ -26,6 +26,8 @@
package org.alfresco.solr; package org.alfresco.solr;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -65,7 +67,20 @@ public class TrackerState
private volatile boolean checkedLastTransactionTime = false; private volatile boolean checkedLastTransactionTime = false;
private volatile boolean check = false; private volatile boolean check = false;
private volatile int trackerCycles; // Handle Thread Safe operations
private volatile TrackerCyclesInteger trackerCycles;
class TrackerCyclesInteger
{
private AtomicInteger value = new AtomicInteger(0);
private void increase()
{
value.incrementAndGet();
}
private int getValue()
{
return value.get();
}
}
private long timeToStopIndexing; private long timeToStopIndexing;
private long lastGoodChangeSetCommitTimeInIndex; private long lastGoodChangeSetCommitTimeInIndex;
@@ -237,13 +252,13 @@ public class TrackerState
public int getTrackerCycles() public int getTrackerCycles()
{ {
return this.trackerCycles; return this.trackerCycles.getValue();
} }
public synchronized void incrementTrackerCycles() public synchronized void incrementTrackerCycles()
{ {
log.debug("incrementTrackerCycles from :" + trackerCycles); log.debug("incrementTrackerCycles from :" + trackerCycles);
this.trackerCycles++; this.trackerCycles.increase();
log.debug("incremented TrackerCycles to :" + trackerCycles); log.debug("incremented TrackerCycles to :" + trackerCycles);
} }
@@ -38,6 +38,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
@@ -741,7 +742,7 @@ public class SOLRAPIClient
String localeStr = o.has("locale") && !o.isNull("locale") ? o.getString("locale") : null; String localeStr = o.has("locale") && !o.isNull("locale") ? o.getString("locale") : null;
Locale locale = (o.has("locale") && !o.isNull("locale") ? deserializer.deserializeValue(Locale.class, localeStr) : null); Locale locale = (o.has("locale") && !o.isNull("locale") ? deserializer.deserializeValue(Locale.class, localeStr) : null);
Long size = o.has("size") && !o.isNull("size") ? o.getLong("size") : null; long size = o.has("size") && !o.isNull("size") ? o.getLong("size") : 0;
String encoding = o.has("encoding") && !o.isNull("encoding") ? o.getString("encoding") : null; String encoding = o.has("encoding") && !o.isNull("encoding") ? o.getString("encoding") : null;
String mimetype = o.has("mimetype") && !o.isNull("mimetype") ? o.getString("mimetype") : null; String mimetype = o.has("mimetype") && !o.isNull("mimetype") ? o.getString("mimetype") : null;
@@ -1247,15 +1248,11 @@ public class SOLRAPIClient
this.namespaceDAO = namespaceDAO; this.namespaceDAO = namespaceDAO;
// add all default converters to this converter // add all default converters to this converter
// TODO find a better way of doing this for (Entry<Class<?>, Map<Class<?>, Converter<?, ?>>> source : DefaultTypeConverter.INSTANCE.getConverters().entrySet())
Map<Class<?>, Map<Class<?>, Converter<?,?>>> converters = DefaultTypeConverter.INSTANCE.getConverters();
for(Class source : converters.keySet())
{ {
Map<Class<?>, Converter<?,?>> converters1 = converters.get(source); for (Entry<Class<?>, Converter<?, ?>> dest : source.getValue().entrySet())
for(Class dest : converters1.keySet())
{ {
Converter<?,?> converter = converters1.get(dest); instance.addConverter((Class) source.getKey(), (Class) dest.getKey(), dest.getValue());
instance.addConverter(source, dest, converter);
} }
} }
@@ -30,8 +30,11 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.concurrent.NotThreadSafe;
import org.alfresco.solr.InformationServerCollectionProvider; import org.alfresco.solr.InformationServerCollectionProvider;
import org.alfresco.solr.adapters.ISimpleOrderedMap; import org.alfresco.solr.adapters.ISimpleOrderedMap;
import org.alfresco.util.Pair; import org.alfresco.util.Pair;
@@ -283,10 +286,9 @@ public class TrackerStats
map.add("StdDev", getStandardDeviation()); map.add("StdDev", getStandardDeviation());
if (incdludeDetail) if (incdludeDetail)
{ {
for (String key : copies.keySet()) for (Entry<String, IncrementalStats> copy : copies.entrySet())
{ {
IncrementalStats value = copies.get(key); map.add(copy.getKey(), copy.getValue().getNamedList(includeHist, includeValues));
map.add(key, value.getNamedList(includeHist, includeValues));
} }
} }
@@ -382,6 +384,7 @@ public class TrackerStats
} }
@NotThreadSafe
public static class IncrementalStats public static class IncrementalStats
{ {
Date start = new Date(); Date start = new Date();
@@ -769,7 +772,7 @@ public class TrackerStats
{ {
IncrementalStats copy = new IncrementalStats(this.scale, this.buckets, this.server); IncrementalStats copy = new IncrementalStats(this.scale, this.buckets, this.server);
copy.start = this.start; copy.start = this.start;
copy.max = this.max; copy.max = this.getMax();
copy.min = this.min; copy.min = this.min;
copy.moments[0] = this.moments[0]; copy.moments[0] = this.moments[0];
copy.moments[1] = this.moments[1]; copy.moments[1] = this.moments[1];