Skip to content

Commit

Permalink
srm: fix credential store logging
Browse files Browse the repository at this point in the history
Motivation:

RuntimeException (bugs) are not logged with a stack-trace.  Errors
returned to the client (and logged) contain just 'null' as an
explanation if the IOException has no message.

Modification:

Ensure bugs trigger a stack-trace.

Ensure returned explanation isn't 'null'.

Result:

Delegation store provides better error reports, should something fail.

Target: master
Request: 4.2
Request: 4.1
Request: 4.0
Request: 3.2
Requires-notes: yes
Requires-book: no
Patch: https://rb.dcache.org/r/11304/
Acked-by: Olufemi Adeyemi
  • Loading branch information
paulmillar committed Oct 29, 2018
1 parent 24de520 commit 41976be
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.dcache.gridsite;

import eu.emi.security.authn.x509.X509Credential;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;

import java.io.IOException;
Expand All @@ -31,6 +33,7 @@
import org.dcache.delegation.gridsite2.DelegationException;
import org.dcache.srm.request.RequestCredential;
import org.dcache.srm.request.RequestCredentialStorage;
import org.dcache.util.Exceptions;
import org.dcache.util.SqlGlob;

import static org.dcache.gridsite.Utilities.assertThat;
Expand All @@ -41,6 +44,8 @@
*/
public class SrmCredentialStore implements CredentialStore
{
private static final Logger LOGGER = LoggerFactory.getLogger(SrmCredentialStore.class);

private RequestCredentialStorage _store;

@Required
Expand All @@ -67,7 +72,8 @@ public void put(DelegationIdentity id, X509Credential credential, FQAN primaryFq
new RequestCredential(nameFromId(id), Objects.toString(primaryFqan, null), credential, _store);
_store.saveRequestCredential(srmCredential);
} catch (RuntimeException e) {
throw new DelegationException("failed to save credential: " + e.getMessage());
LOGGER.warn("Bug detected please report to <support@dcache.org>: ", e);
throw new DelegationException("failed to save credential: " + Exceptions.messageOrClassName(e));
}
}

Expand All @@ -79,7 +85,7 @@ public void remove(DelegationIdentity id) throws DelegationException
try {
isSuccessful = _store.deleteRequestCredential(nameFromId(id), null);
} catch (IOException e) {
throw new DelegationException("internal problem: " + e.getMessage());
throw new DelegationException("internal problem: " + Exceptions.messageOrClassName(e));
}

assertThat(isSuccessful, "no credential", id);
Expand All @@ -91,7 +97,7 @@ public boolean has(DelegationIdentity id) throws DelegationException
try {
return _store.hasRequestCredential(nameFromId(id), null);
} catch (IOException e) {
throw new DelegationException("internal problem: " + e.getMessage());
throw new DelegationException("internal problem: " + Exceptions.messageOrClassName(e));
}
}

Expand Down

0 comments on commit 41976be

Please sign in to comment.