Skip to content

Commit

Permalink
portmap: use constants instead of magic numbers
Browse files Browse the repository at this point in the history
Motivation:
avoid magic numbers

Modification:
use constants instead of magic numbers

Result:
better code (?)

target: master
Acked-by: Albert Rossi
  • Loading branch information
kofemann committed Aug 6, 2018
1 parent fe4cf32 commit 85ad969
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.dcache.oncrpc4j.rpc.net.IpProtocolType;
import org.dcache.oncrpc4j.rpc.OncRpcClient;
import org.dcache.oncrpc4j.rpc.OncRpcException;
import org.dcache.oncrpc4j.rpc.OncRpcSvc;
import org.dcache.oncrpc4j.rpc.OncRpcSvcBuilder;
import org.dcache.oncrpc4j.rpc.RpcAuth;
import org.dcache.oncrpc4j.rpc.RpcAuthTypeNone;
import org.dcache.oncrpc4j.rpc.RpcCall;
import org.dcache.oncrpc4j.rpc.RpcProgUnavailable;
import org.dcache.oncrpc4j.rpc.RpcTransport;

import static org.dcache.oncrpc4j.portmap.OncRpcPortmap.PORTMAP_PROGRAMM;
import static org.dcache.oncrpc4j.portmap.OncRpcPortmap.PORTMAP_V4;
import static org.dcache.oncrpc4j.portmap.OncRpcPortmap.PORTMAP_V2;

public class GenericPortmapClient implements OncPortmapClient {

private final static Logger _log = LoggerFactory.getLogger(GenericPortmapClient.class);
Expand All @@ -45,9 +46,9 @@ public class GenericPortmapClient implements OncPortmapClient {

public GenericPortmapClient(RpcTransport transport) throws RpcProgUnavailable {

OncPortmapClient portmapClient = new RpcbindV4Client(new RpcCall(100000, 4, _auth, transport));
OncPortmapClient portmapClient = new RpcbindV4Client(new RpcCall(PORTMAP_PROGRAMM, PORTMAP_V4, _auth, transport));
if( !portmapClient.ping() ) {
portmapClient = new PortmapV2Client( new RpcCall(100000, 2, _auth, transport) );
portmapClient = new PortmapV2Client( new RpcCall(PORTMAP_PROGRAMM, PORTMAP_V2, _auth, transport) );
if(!portmapClient.ping()) {
// FIXME: return correct exception
throw new RpcProgUnavailable("portmap service not available");
Expand Down

0 comments on commit 85ad969

Please sign in to comment.