Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marevol committed Aug 12, 2023
1 parent 3bbed94 commit 62664ac
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

public interface FessTransformer {

Map<String, String> parentEncodingMap = Collections.synchronizedMap(new LruHashMap<String, String>(1000));
Map<String, String> parentEncodingMap = Collections.synchronizedMap(new LruHashMap<>(1000));

FessConfig getFessConfig();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected ExecutorService newFixedThreadPool(final int nThreads) {
if (logger.isDebugEnabled()) {
logger.debug("Executor Thread Pool: {}", nThreads);
}
return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(nThreads),
return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(nThreads),
new ThreadPoolExecutor.CallerRunsPolicy());
}

Expand Down Expand Up @@ -181,7 +181,7 @@ protected void addDocument(final DataStoreParams paramMap, final Map<String, Obj
final Throwable cause = e.getCause();
if (cause instanceof ChildUrlsException) {
((ChildUrlsException) cause).getChildUrlList().stream().map(RequestData::getUrl).forEach(s -> {
if (!processedUrls.contains(s)&&!urlQueue.contains(s)) {
if (!processedUrls.contains(s) && !urlQueue.contains(s)) {
urlQueue.offer(s);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.codelibs.fess.crawler.client.smb.SmbClient;
import org.codelibs.fess.crawler.exception.CrawlerSystemException;
import org.codelibs.fess.es.config.bsentity.BsDataConfig;
import org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigName;
import org.codelibs.fess.util.ParameterUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public synchronized void store(final String sessionId, final boolean create) {

public synchronized void putToInfoMap(final String key, final String value) {
if (infoMap == null) {
infoMap = Collections.synchronizedMap(new LinkedHashMap<String, String>());
infoMap = Collections.synchronizedMap(new LinkedHashMap<>());
}
logger.debug("infoMap: {}={} => {}", key, value, infoMap);
infoMap.put(key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class DataIndexHelper {

protected int crawlerPriority = Thread.NORM_PRIORITY;

protected final List<DataCrawlingThread> dataCrawlingThreadList = Collections.synchronizedList(new ArrayList<DataCrawlingThread>());
protected final List<DataCrawlingThread> dataCrawlingThreadList = Collections.synchronizedList(new ArrayList<>());

public void crawl(final String sessionId) {
final List<DataConfig> configList = ComponentUtil.getCrawlingConfigHelper().getAllDataConfigList();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/codelibs/fess/helper/IndexingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void sendDocuments(final SearchEngineClient searchEngineClient, final Doc
docList.stream().forEach(doc -> {
if (!thumbnailManager.offer(doc)) {
if (logger.isDebugEnabled()) {
logger.debug("Removing {} from {}", doc.get(fessConfig.getIndexFieldThumbnail()),
doc.get(fessConfig.getIndexFieldUrl()));
logger.debug("Removing {}={} from doc[{}]", fessConfig.getIndexFieldThumbnail(),
doc.get(fessConfig.getIndexFieldThumbnail()), doc.get(fessConfig.getIndexFieldUrl()));
}
doc.remove(fessConfig.getIndexFieldThumbnail());
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/codelibs/fess/helper/PermissionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,19 @@ public List<String> getFileRoleTypeList(final ResponseData responseData) {
final Map<String, Object> metaDataMap = responseData.getMetaDataMap();
final Object fileAttributeView = metaDataMap.get(FileSystemClient.FILE_ATTRIBUTE_VIEW);
try {
if (fileAttributeView instanceof AclFileAttributeView aclFileAttributeView) {
if (fileAttributeView instanceof final AclFileAttributeView aclFileAttributeView) {
aclFileAttributeView.getAcl().stream().forEach(acl -> {
final UserPrincipal principal = acl.principal();
if (logger.isDebugEnabled()) {
logger.debug("Principal: [{}] {}", principal.getClass().getName(), principal);
}
if (principal instanceof GroupPrincipal groupPrincipal) {
if (principal instanceof final GroupPrincipal groupPrincipal) {
roleTypeList.add(systemHelper.getSearchRoleByGroup(groupPrincipal.getName()));
} else if (principal != null) {
roleTypeList.add(systemHelper.getSearchRoleByUser(principal.getName()));
}
});
} else if (fileAttributeView instanceof PosixFileAttributeView posixFileAttributeView) {
} else if (fileAttributeView instanceof final PosixFileAttributeView posixFileAttributeView) {
final PosixFileAttributes attributes = posixFileAttributeView.readAttributes();
final UserPrincipal userPrincipal = attributes.owner();
if (logger.isDebugEnabled()) {
Expand All @@ -239,7 +239,7 @@ public List<String> getFileRoleTypeList(final ResponseData responseData) {
roleTypeList.add(systemHelper.getSearchRoleByGroup(groupPrincipal.getName()));
}
}
} catch (IOException e) {
} catch (final IOException e) {
throw new CrawlingAccessException("Failed to access permission info", e);
}
if (logger.isDebugEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/codelibs/fess/helper/SystemHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ public String updateConfiguration() {
buf.append(e.getKey()).append(": ");
try {
buf.append(e.getValue().get());
} catch (Exception ex) {
} catch (final Exception ex) {
logger.warn("Failed to process {} task.", e.getKey(), ex);
buf.append(ex.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class WebFsIndexHelper {

protected int crawlerPriority = Thread.NORM_PRIORITY;

protected final List<Crawler> crawlerList = Collections.synchronizedList(new ArrayList<Crawler>());
protected final List<Crawler> crawlerList = Collections.synchronizedList(new ArrayList<>());

public void crawl(final String sessionId, final List<String> webConfigIdList, final List<String> fileConfigIdList) {
final boolean runAll = webConfigIdList == null && fileConfigIdList == null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void init() {
}
}

@Override
@PreDestroy
public void close() throws Exception {
if (executorService != null) {
Expand Down Expand Up @@ -163,8 +164,8 @@ protected List<Map<String, Object>> searchWithMultipleSearchers(final String que
if (doc.get(idField) instanceof final String id) {
final float score = 1.0f / (rankConstant + j);
if (scoreDocMap.containsKey(id)) {
Map<String, Object> baseDoc = scoreDocMap.get(id);
float oldScore = toFloat(baseDoc.get(scoreField));
final Map<String, Object> baseDoc = scoreDocMap.get(id);
final float oldScore = toFloat(baseDoc.get(scoreField));
baseDoc.put(scoreField, oldScore + score);
} else {
doc.put(scoreField, Float.valueOf(score));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ protected void processMemberOf(final AzureAdUser user, final List<String> groupL
}
}

protected void addGroupOrRoleName(List<String> list, String value, boolean useDomainServices) {
protected void addGroupOrRoleName(final List<String> list, final String value, final boolean useDomainServices) {
list.add(value);
if (useDomainServices && value.indexOf('@') >= 0) {
String[] values = value.split("@");
final String[] values = value.split("@");
if (values.length > 1) {
list.add(values[0]);
}
Expand Down

0 comments on commit 62664ac

Please sign in to comment.