NIFI-9815 Corrected log message formatting in multiple classes

This closes #5879

Signed-off-by: Mike Thomsen <mthomsen@apache.org>
This commit is contained in:
exceptionfactory 2022-03-18 11:46:43 -05:00 committed by Mike Thomsen
parent 193bcbe33a
commit 7823156606
No known key found for this signature in database
GPG Key ID: 88511C3D4CAD246F
16 changed files with 28 additions and 36 deletions

View File

@ -1032,7 +1032,7 @@ public class RunNiFi {
final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos); final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos);
if (waitSeconds >= gracefulShutdownSeconds && gracefulShutdownSeconds > 0) { if (waitSeconds >= gracefulShutdownSeconds && gracefulShutdownSeconds > 0) {
if (isProcessRunning(pid, logger)) { if (isProcessRunning(pid, logger)) {
logger.warn("NiFi PID [{}] shutdown not completed after {} seconds: Killing process", gracefulShutdownSeconds); logger.warn("NiFi PID [{}] shutdown not completed after {} seconds: Killing process", pid, gracefulShutdownSeconds);
try { try {
killProcessTree(pid, logger); killProcessTree(pid, logger);
} catch (final IOException ioe) { } catch (final IOException ioe) {

View File

@ -181,7 +181,7 @@ public class CompositeUserGroupProvider implements UserGroupProvider {
compositeUserAndGroups.setUser(userAndGroups.getUser()); compositeUserAndGroups.setUser(userAndGroups.getUser());
providerClassForUser = userGroupProvider.getClass().getName(); providerClassForUser = userGroupProvider.getClass().getName();
} else { } else {
logger.warn("Multiple UserGroupProviders are claiming to provide user '{}': [{} and {}] ", logger.warn("Multiple UserGroupProviders are claiming to provide identity [{}] user '{}': [{} and {}] ",
identity, identity,
userAndGroups.getUser(), userAndGroups.getUser(),
providerClassForUser, userGroupProvider.getClass().getName()); providerClassForUser, userGroupProvider.getClass().getName());

View File

@ -77,7 +77,7 @@ public class NiFiRegistryNarProvider implements NarProvider {
final Set<NiFiRegistryExtensionBundleMetadata> bundleMetadata = extensionRegistry.getExtensionBundleMetadata(null); final Set<NiFiRegistryExtensionBundleMetadata> bundleMetadata = extensionRegistry.getExtensionBundleMetadata(null);
return bundleMetadata.stream().map(bm -> bm.toLocationString()).collect(Collectors.toSet()); return bundleMetadata.stream().map(bm -> bm.toLocationString()).collect(Collectors.toSet());
} catch (final ExtensionRegistryException ere) { } catch (final ExtensionRegistryException ere) {
LOGGER.error("Unable to retrieve listing of NARs from NiFi Registry at []", extensionRegistry.getURL(), ere); LOGGER.error("Unable to retrieve listing of NARs from NiFi Registry at [{}]", extensionRegistry.getURL(), ere);
return Collections.emptySet(); return Collections.emptySet();
} }
} }

View File

@ -172,7 +172,7 @@ public class SocketRemoteSiteListener implements RemoteSiteListener {
} }
} catch (final Exception e) { } catch (final Exception e) {
// TODO: Add SocketProtocolListener#handleTlsError logic here // TODO: Add SocketProtocolListener#handleTlsError logic here
String msg = String.format("RemoteSiteListener Unable to accept connection from {} due to {}", socket, e.getLocalizedMessage()); String msg = String.format("RemoteSiteListener Unable to accept connection from %s due to %s", socket, e.getLocalizedMessage());
// Suppress repeated TLS errors // Suppress repeated TLS errors
if (CertificateUtils.isTlsError(e)) { if (CertificateUtils.isTlsError(e)) {
boolean printedAsWarning = handleTlsError(msg); boolean printedAsWarning = handleTlsError(msg);

View File

@ -150,7 +150,7 @@ public abstract class AbstractFlowFileServerProtocol implements ServerProtocol {
this.port = (PublicPort) receivedPort; this.port = (PublicPort) receivedPort;
final PortAuthorizationResult portAuthResult = this.port.checkUserAuthorization(peer.getCommunicationsSession().getUserDn()); final PortAuthorizationResult portAuthResult = this.port.checkUserAuthorization(peer.getCommunicationsSession().getUserDn());
if (!portAuthResult.isAuthorized()) { if (!portAuthResult.isAuthorized()) {
logger.debug("Responding with ResponseCode UNAUTHORIZED: ", portAuthResult.getExplanation()); logger.debug("Responding with ResponseCode UNAUTHORIZED: {}", portAuthResult.getExplanation());
throw new HandshakeException(ResponseCode.UNAUTHORIZED, portAuthResult.getExplanation()); throw new HandshakeException(ResponseCode.UNAUTHORIZED, portAuthResult.getExplanation());
} }

View File

@ -197,8 +197,6 @@ public class DataTransferResource extends ApplicationResource {
return validationResult.errResponse; return validationResult.errResponse;
} }
logger.debug("createPortTransaction request: clientId={}, portType={}, portId={}", portType, portId);
final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream out = new ByteArrayOutputStream();
final String transactionId = transactionManager.createTransaction(); final String transactionId = transactionManager.createTransaction();
final Peer peer = constructPeer(req, inputStream, out, portId, transactionId); final Peer peer = constructPeer(req, inputStream, out, portId, transactionId);

View File

@ -81,9 +81,8 @@ import java.util.regex.Pattern;
public class OIDCAccessResource extends ApplicationResource { public class OIDCAccessResource extends ApplicationResource {
private static final Logger logger = LoggerFactory.getLogger(OIDCAccessResource.class); private static final Logger logger = LoggerFactory.getLogger(OIDCAccessResource.class);
private static final String OIDC_AUTHENTICATION_FAILED = "OIDC authentication attempt failed: "; private static final String OIDC_AUTHENTICATION_NOT_CONFIGURED = "OIDC authentication not configured";
private static final String OIDC_ID_TOKEN_AUTHN_ERROR = "Unable to exchange authorization for ID token: "; private static final String OIDC_ID_TOKEN_AUTHN_ERROR = "Unable to exchange authorization for ID token: ";
private static final String OIDC_IS_NOT_CONFIGURED_MESSAGE = "OIDC is not configured.";
private static final String OIDC_REQUEST_IDENTIFIER_NOT_FOUND = "The request identifier was not found in the request."; private static final String OIDC_REQUEST_IDENTIFIER_NOT_FOUND = "The request identifier was not found in the request.";
private static final String OIDC_FAILED_TO_PARSE_REDIRECT_URI = "Unable to parse the redirect URI from the OpenId Connect Provider. Unable to continue login/logout process."; private static final String OIDC_FAILED_TO_PARSE_REDIRECT_URI = "Unable to parse the redirect URI from the OpenId Connect Provider. Unable to continue login/logout process.";
private static final String REVOKE_ACCESS_TOKEN_LOGOUT = "oidc_access_token_logout"; private static final String REVOKE_ACCESS_TOKEN_LOGOUT = "oidc_access_token_logout";
@ -193,7 +192,7 @@ public class OIDCAccessResource extends ApplicationResource {
try { try {
validateOidcConfiguration(); validateOidcConfiguration();
} catch (final AuthenticationNotSupportedException e) { } catch (final AuthenticationNotSupportedException e) {
logger.debug(OIDC_AUTHENTICATION_FAILED, e.getMessage()); logger.debug("OIDC authentication not supported", e);
return Response.status(Response.Status.CONFLICT).entity(e.getMessage()).build(); return Response.status(Response.Status.CONFLICT).entity(e.getMessage()).build();
} }
@ -230,7 +229,6 @@ public class OIDCAccessResource extends ApplicationResource {
try { try {
validateOidcConfiguration(); validateOidcConfiguration();
} catch (final AuthenticationNotSupportedException e) { } catch (final AuthenticationNotSupportedException e) {
logger.debug(OIDC_AUTHENTICATION_FAILED, e.getMessage());
throw e; throw e;
} }
@ -471,7 +469,6 @@ public class OIDCAccessResource extends ApplicationResource {
try { try {
validateOidcConfiguration(); validateOidcConfiguration();
} catch (final AuthenticationNotSupportedException e) { } catch (final AuthenticationNotSupportedException e) {
logger.debug(OIDC_AUTHENTICATION_FAILED, e.getMessage());
forwardToMessagePage(httpServletRequest, httpServletResponse, pageTitle, e.getMessage()); forwardToMessagePage(httpServletRequest, httpServletResponse, pageTitle, e.getMessage());
throw e; throw e;
} }
@ -529,7 +526,7 @@ public class OIDCAccessResource extends ApplicationResource {
// ensure OIDC is actually configured/enabled // ensure OIDC is actually configured/enabled
if (!oidcService.isOidcEnabled()) { if (!oidcService.isOidcEnabled()) {
throw new AuthenticationNotSupportedException(OIDC_IS_NOT_CONFIGURED_MESSAGE); throw new AuthenticationNotSupportedException(OIDC_AUTHENTICATION_NOT_CONFIGURED);
} }
} }

View File

@ -1590,7 +1590,7 @@ public class PersistentProvenanceRepository implements ProvenanceRepository {
// we have all "partial" files and there is already a merged file. Delete the data from the index // we have all "partial" files and there is already a merged file. Delete the data from the index
// because the merge file may not be fully merged. We will re-merge. // because the merge file may not be fully merged. We will re-merge.
logger.warn("Merged Journal File {} already exists; however, all partial journal files also exist " logger.warn("Merged Journal File {} already exists; however, all partial journal files also exist "
+ "so assuming that the merge did not finish. Repeating procedure in order to ensure consistency."); + "so assuming that the merge did not finish. Repeating procedure in order to ensure consistency.", suggestedMergeFile);
final DeleteIndexAction deleteAction = new DeleteIndexAction(this, indexConfig, getIndexManager()); final DeleteIndexAction deleteAction = new DeleteIndexAction(this, indexConfig, getIndexManager());
try { try {

View File

@ -455,13 +455,13 @@ public class IndexDirectoryManager {
// We didn't find the old index directory. Just add the new index directory. // We didn't find the old index directory. Just add the new index directory.
final long timestamp = DirectoryUtils.getIndexTimestamp(indexDirectory); final long timestamp = DirectoryUtils.getIndexTimestamp(indexDirectory);
if (timestamp < 0) { if (timestamp < 0) {
logger.debug("Attempted to replace old index directory {} with new index directory {} but the old index directory did not " + logger.debug("Attempted to replace old index directory {} with new index directory but the old index directory did not " +
"exist and could not determine timestamp for new index directory"); "exist and could not determine timestamp for new index directory", indexDirectory);
} else { } else {
final String partitionName = getPartitionName(indexDirectory); final String partitionName = getPartitionName(indexDirectory);
if (partitionName == null) { if (partitionName == null) {
logger.debug("Attempted to replace old index directory {} with new index directory {} but the old index directory did not " + logger.debug("Attempted to replace old index directory {} with new index directory but the old index directory did not " +
"exist and could not determine partition name for new index directory"); "exist and could not determine partition name for new index directory", indexDirectory);
} else { } else {
final IndexLocation indexLocation = new IndexLocation(indexDirectory, timestamp, partitionName); final IndexLocation indexLocation = new IndexLocation(indexDirectory, timestamp, partitionName);
indexLocationByTimestamp.computeIfAbsent(timestamp, key -> new ArrayList<>()).add(indexLocation); indexLocationByTimestamp.computeIfAbsent(timestamp, key -> new ArrayList<>()).add(indexLocation);

View File

@ -33,6 +33,7 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays;
@Configuration @Configuration
public class CustomFlywayConfiguration implements FlywayConfigurationCustomizer { public class CustomFlywayConfiguration implements FlywayConfigurationCustomizer {
@ -58,13 +59,13 @@ public class CustomFlywayConfiguration implements FlywayConfigurationCustomizer
LOGGER.info("Determined database type is {}", databaseType.getName()); LOGGER.info("Determined database type is {}", databaseType.getName());
if (databaseType.equals(new MySQLDatabaseType())) { if (databaseType.equals(new MySQLDatabaseType())) {
LOGGER.info("Setting migration locations to {}", LOCATIONS_MYSQL); LOGGER.info("Setting migration locations to {}", Arrays.asList(LOCATIONS_MYSQL));
configuration.locations(LOCATIONS_MYSQL); configuration.locations(LOCATIONS_MYSQL);
} else if (databaseType.equals(new PostgreSQLDatabaseType())) { } else if (databaseType.equals(new PostgreSQLDatabaseType())) {
LOGGER.info("Setting migration locations to {}", LOCATIONS_POSTGRES); LOGGER.info("Setting migration locations to {}", Arrays.asList(LOCATIONS_POSTGRES));
configuration.locations(LOCATIONS_POSTGRES); configuration.locations(LOCATIONS_POSTGRES);
} else { } else {
LOGGER.info("Setting migration locations to {}", LOCATIONS_DEFAULT); LOGGER.info("Setting migration locations to {}", Arrays.asList(LOCATIONS_DEFAULT));
configuration.locations(LOCATIONS_DEFAULT); configuration.locations(LOCATIONS_DEFAULT);
} }

View File

@ -63,7 +63,7 @@ public class ScriptEventHookProvider
try { try {
builder.start(); builder.start();
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Execution of {0} failed with: {1}", new Object[] { commandString, e.getLocalizedMessage() }, e); LOGGER.error("Command Execution Failed: {}", commandString, e);
} }
} }
@ -93,7 +93,7 @@ public class ScriptEventHookProvider
scriptFile = new File(scripPath); scriptFile = new File(scripPath);
if(scriptFile.isFile() && scriptFile.canExecute()) { if(scriptFile.isFile() && scriptFile.canExecute()) {
LOGGER.info("Configured ScriptEventHookProvider with script {}", new Object[] {scriptFile.getAbsolutePath()}); LOGGER.info("Configured ScriptEventHookProvider with script {}", scriptFile.getAbsolutePath());
} else { } else {
throw new ProviderCreationException("The script file " + scriptFile.getAbsolutePath() + " cannot be executed."); throw new ProviderCreationException("The script file " + scriptFile.getAbsolutePath() + " cannot be executed.");
} }

View File

@ -167,7 +167,7 @@ public class CompositeUserGroupProvider implements UserGroupProvider {
compositeUserAndGroups.setUser(userAndGroups.getUser()); compositeUserAndGroups.setUser(userAndGroups.getUser());
providerClassForUser = userGroupProvider.getClass().getName(); providerClassForUser = userGroupProvider.getClass().getName();
} else { } else {
logger.warn("Multiple UserGroupProviders are claiming to provide user '{}': [{} and {}] ", logger.warn("Multiple UserGroupProviders are claiming to provide identity [{}] user '{}': [{} and {}] ",
identity, identity,
userAndGroups.getUser(), userAndGroups.getUser(),
providerClassForUser, userGroupProvider.getClass().getName()); providerClassForUser, userGroupProvider.getClass().getName());

View File

@ -333,7 +333,7 @@ public class AuthorizationService {
final Group group = userGroupProvider.getGroup(identifier); final Group group = userGroupProvider.getGroup(identifier);
if (group == null) { if (group == null) {
LOGGER.warn("The specified user group id [{}] does not exist.", group.getIdentifier()); LOGGER.warn("The specified user group id [{}] does not exist.", identifier);
throw new ResourceNotFoundException("The specified user group ID does not exist in this registry."); throw new ResourceNotFoundException("The specified user group ID does not exist in this registry.");
} }

View File

@ -89,7 +89,7 @@ public class IdentityMappingUtil {
final String identityPattern = properties.getProperty(propertyName); final String identityPattern = properties.getProperty(propertyName);
if (StringUtils.isBlank(identityPattern)) { if (StringUtils.isBlank(identityPattern)) {
LOGGER.warn("{} Mapping property {} was found, but was empty", new Object[] {getSubject.get(), propertyName}); LOGGER.warn("{} Mapping property {} was found, but was empty", getSubject.get(), propertyName);
continue; continue;
} }
@ -98,7 +98,7 @@ public class IdentityMappingUtil {
if (StringUtils.isBlank(identityValue)) { if (StringUtils.isBlank(identityValue)) {
LOGGER.warn("{} Mapping property {} was found, but corresponding value {} was not found", LOGGER.warn("{} Mapping property {} was found, but corresponding value {} was not found",
new Object[]{propertyName, identityValueProperty}); getSubject.get(), propertyName, identityValueProperty);
continue; continue;
} }
@ -106,7 +106,7 @@ public class IdentityMappingUtil {
String rawIdentityTransform = properties.getProperty(identityTransformProperty); String rawIdentityTransform = properties.getProperty(identityTransformProperty);
if (StringUtils.isBlank(rawIdentityTransform)) { if (StringUtils.isBlank(rawIdentityTransform)) {
LOGGER.debug("{} Mapping property {} was found, but no transform was present. Using NONE.", new Object[] {getSubject.get(), propertyName}); LOGGER.debug("{} Mapping property {} was found, but no transform was present. Using NONE.", getSubject.get(), propertyName);
rawIdentityTransform = IdentityMapping.Transform.NONE.name(); rawIdentityTransform = IdentityMapping.Transform.NONE.name();
} }
@ -115,7 +115,7 @@ public class IdentityMappingUtil {
identityTransform = Transform.valueOf(rawIdentityTransform); identityTransform = Transform.valueOf(rawIdentityTransform);
} catch (final IllegalArgumentException iae) { } catch (final IllegalArgumentException iae) {
LOGGER.warn("{} Mapping property {} was found, but corresponding transform {} was not valid. Allowed values {}", LOGGER.warn("{} Mapping property {} was found, but corresponding transform {} was not valid. Allowed values {}",
new Object[] {getSubject.get(), propertyName, rawIdentityTransform, StringUtils.join(Transform.values(), ", ")}); getSubject.get(), propertyName, rawIdentityTransform, StringUtils.join(Transform.values(), ", "));
continue; continue;
} }
@ -123,7 +123,7 @@ public class IdentityMappingUtil {
mappings.add(identityMapping); mappings.add(identityMapping);
LOGGER.debug("Found {} Mapping with key = {}, pattern = {}, value = {}, transform = {}", LOGGER.debug("Found {} Mapping with key = {}, pattern = {}, value = {}, transform = {}",
new Object[] {getSubject.get(), key, identityPattern, identityValue, rawIdentityTransform}); getSubject.get(), key, identityPattern, identityValue, rawIdentityTransform);
} }
} }

View File

@ -67,7 +67,7 @@ public class KerberosSpnegoIdentityProvider implements IdentityProvider {
private static final String AUTHORIZATION = "Authorization"; private static final String AUTHORIZATION = "Authorization";
private static final String AUTHORIZATION_NEGOTIATE = "Negotiate"; private static final String AUTHORIZATION_NEGOTIATE = "Negotiate";
private long expiration = TimeUnit.MILLISECONDS.convert(12, TimeUnit.HOURS);; private long expiration = TimeUnit.MILLISECONDS.convert(12, TimeUnit.HOURS);
private KerberosServiceAuthenticationProvider kerberosServiceAuthenticationProvider; private KerberosServiceAuthenticationProvider kerberosServiceAuthenticationProvider;
private AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource; private AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource;
@ -106,10 +106,6 @@ public class KerberosSpnegoIdentityProvider implements IdentityProvider {
logger.debug("Detected 'Authorization: Negotiate header in request {}", request.getRequestURL()); logger.debug("Detected 'Authorization: Negotiate header in request {}", request.getRequestURL());
byte[] base64Token = headerValue.substring(headerValue.indexOf(" ") + 1).getBytes(StandardCharsets.UTF_8); byte[] base64Token = headerValue.substring(headerValue.indexOf(" ") + 1).getBytes(StandardCharsets.UTF_8);
byte[] kerberosTicket = Base64.decode(base64Token); byte[] kerberosTicket = Base64.decode(base64Token);
if (kerberosTicket != null) {
logger.debug("Successfully decoded SPNEGO/Kerberos ticket passed in Authorization: Negotiate <ticket> header.", request.getRequestURL());
}
return new AuthenticationRequest(null, kerberosTicket, authenticationDetailsSource.buildDetails(request)); return new AuthenticationRequest(null, kerberosTicket, authenticationDetailsSource.buildDetails(request));
} }

View File

@ -281,7 +281,7 @@ public class TlsHelper {
// Already in PKCS #1 format // Already in PKCS #1 format
return getKeyPair((PEMKeyPair)parsedObject); return getKeyPair((PEMKeyPair)parsedObject);
} else { } else {
logger.warn("Expected one of %s or %s but got %s", PrivateKeyInfo.class, PEMKeyPair.class, parsedObject.getClass()); logger.warn("Expected one of {} or {} but got {}", PrivateKeyInfo.class, PEMKeyPair.class, parsedObject.getClass());
throw new IOException("Expected private key in PKCS #1 or PKCS #8 unencrypted format"); throw new IOException("Expected private key in PKCS #1 or PKCS #8 unencrypted format");
} }
} }