Skip to content

Commit

Permalink
httpd: check for null Subject in Transfer info
Browse files Browse the repository at this point in the history
Motivation:

The httpd transfer collector classes periodically send
requests to the login broker.  Under certain conditions
it is possible for the reply to contain incomplete
information.  This is particularly true if the reply is sent
before login or file resolution has completed.

Since the TransferObserver and webadmin mapper classes attempt
to convert the Subject into a UserInfo object using the Subjects
methods, a NPE is generated if the Subject is null.

Modification:

Check for the null subject where UserInfo is set and
provide a UserInfo object with an empty constructor in
that case.

Result:

No NullPointerException.

Affects only master (changes introduced by 9258).

Target: master
Acked-by: Gerd
  • Loading branch information
alrossi committed Jun 15, 2016
1 parent dd15a13 commit a8d9592
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public String getStatus()
return _status;
}

/**
* Under certain conditions it is possible to receive
* transfer info sent before login has been performed
* by the door. It is thus possible that the Subject
* also be <code>null</code>.
*/
@Nullable
public Subject getSubject()
{
return _subject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import diskCacheV111.pools.PoolCostInfo.PoolQueueInfo;
import diskCacheV111.services.space.LinkGroup;
import diskCacheV111.services.space.Space;
import diskCacheV111.util.UserInfo;
import diskCacheV111.util.VOInfo;
import diskCacheV111.vehicles.IoJobInfo;
import diskCacheV111.vehicles.RestoreHandlerInfo;
Expand Down Expand Up @@ -126,7 +127,11 @@ public static ActiveTransfersBean moverModelToView(TransferCollector.Transfer tr
ActiveTransfersBean bean = new ActiveTransfersBean();
bean.setDomainName(transfer.door().getDomainName());
bean.setCellName(transfer.door().getCellName());
bean.setSubject(transfer.session().getSubject());
if (transfer.session().getSubject() == null) {
bean.setUserInfo(new UserInfo());
} else {
bean.setSubject(transfer.session().getSubject());
}
if (transfer.session().getPnfsId() == null) {
bean.setPnfsId("");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import javax.security.auth.Subject;

import diskCacheV111.util.HTMLBuilder;
import diskCacheV111.util.TransferInfo;
import diskCacheV111.util.UserInfo;
import diskCacheV111.vehicles.IoDoorInfo;
import diskCacheV111.vehicles.IoJobInfo;
import dmg.cells.nucleus.CellAdapter;
Expand Down Expand Up @@ -167,7 +169,12 @@ public TransferBean(Transfer transfer, long now) {
serialId = transfer.session().getSerialId();
setProtocol(transfer.door().getProtocolFamily(),
transfer.door().getProtocolVersion());
setSubject(transfer.session().getSubject());
Subject subject = transfer.session().getSubject();
if (subject == null) {
setUserInfo(new UserInfo());
} else {
setSubject(subject);
}
process = transfer.door().getProcess();
pnfsId = Objects.toString(transfer.session().getPnfsId(), "");
pool = Objects.toString(transfer.session().getPool(), "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.security.auth.Subject;
import java.io.Serializable;
import java.util.NoSuchElementException;
import javax.security.auth.Subject;

import org.dcache.auth.FQAN;
import org.dcache.auth.Subjects;
Expand Down

0 comments on commit a8d9592

Please sign in to comment.