Skip to content

Commit

Permalink
Improved usage of Logger
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Apr 15, 2021
1 parent 59765c8 commit bc1415c
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/**
* CORS {@link Filter} implementation.
* <p>
* This filter handles the CORS request per-scope basis.
*
* @since 1.5.0
*/
public class CORSResponseFilter implements Filter {

private final Logger logger = LoggerFactory.getLogger(CORSResponseFilter.class);
Expand Down Expand Up @@ -170,6 +177,7 @@ private synchronized void initRefreshThread(int intervalSecs) {
private synchronized void refreshOrigins() {
try {
logger.info("Refreshing list of origins...");

Multimap<String, KapuaId> newAllowedOrigins = HashMultimap.create();
AccountQuery accounts = accountFactory.newQuery(null);
AccountListResult accountListResult = KapuaSecurityUtils.doPrivileged(() -> accountService.query(accounts));
Expand All @@ -182,18 +190,20 @@ private synchronized void refreshOrigins() {
logger.warn("Unable to add endpoints for account {} to CORS filter", account.getId().toCompactId(), kapuaException);
}
});

for (String allowedSystemOrigin : allowedSystemOrigins) {
try {
String explicitAllowedSystemOrigin = getExplicitOrigin(allowedSystemOrigin);
newAllowedOrigins.put(explicitAllowedSystemOrigin, KapuaId.ANY);
} catch (MalformedURLException malformedURLException) {
logger.warn(String.format("Unable to parse origin %s", allowedSystemOrigin), malformedURLException);
logger.warn("Unable to parse origin: {}", allowedSystemOrigin, malformedURLException);
}
}
allowedOrigins = newAllowedOrigins;
logger.info("Refreshing list of origins... DONE!");

logger.info("Refreshing list of origins... DONE! Loaded {} origins", allowedOrigins.size());
} catch (Exception exception) {
logger.warn("Unable to refresh list of origins", exception);
logger.warn("Refreshing list of origins... ERROR!", exception);
}
}
}

0 comments on commit bc1415c

Please sign in to comment.