Skip to content

Commit

Permalink
FGJ-38 Throw exception if no discovery peers
Browse files Browse the repository at this point in the history
If discovery is set to true but the the channel definition
in the networkconfig doesn’t contain any peers with the
 ‘discover’ role, then a NPE is thrown.
It now throws a checked ServiceDiscoveryException

Change-Id: I43da4804119dd12df364e975af303e9f617dc355
Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
  • Loading branch information
andrew-coleman authored and bestbeforetoday committed Oct 17, 2019
1 parent c643cbc commit 84681e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/hyperledger/fabric/sdk/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public class Channel implements Serializable {
private static final String CHAINCODE_EVENTS_TAG = "CHAINCODE_EVENTS_HANDLE";
final Collection<Orderer> orderers = Collections.synchronizedCollection(new LinkedList<>());
private transient Map<String, Orderer> ordererEndpointMap = Collections.synchronizedMap(new HashMap<>());

// Name of the channel is only meaningful to the client
private final String name;
private transient String toString;
Expand Down Expand Up @@ -384,7 +383,6 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
for (Orderer orderer : orderers) {
ordererEndpointMap.put(orderer.getEndpoint(), orderer);
}

}

/**
Expand Down Expand Up @@ -4387,6 +4385,9 @@ public Collection<ProposalResponse> sendTransactionProposalToEndorsers(Transacti
if (transactionProposalRequest.getChaincodeID() == null) {
throw new InvalidArgumentException("The proposalRequest's chaincode ID is null");
}
if (null == serviceDiscovery) {
throw new ServiceDiscoveryException("The channel is not configured with any peers with the 'discover' role");
}
logger.debug(format("Channel %s sendTransactionProposalToEndorsers chaincode name: %s", name, chaincodeName));

TransactionContext transactionContext = getTransactionContext(transactionProposalRequest.getUserContext());
Expand Down

0 comments on commit 84681e1

Please sign in to comment.