Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 84681e1

Browse files
andrew-colemanbestbeforetoday
authored andcommitted
FGJ-38 Throw exception if no discovery peers
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>
1 parent c643cbc commit 84681e1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/hyperledger/fabric/sdk/Channel.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ public class Channel implements Serializable {
166166
private static final String CHAINCODE_EVENTS_TAG = "CHAINCODE_EVENTS_HANDLE";
167167
final Collection<Orderer> orderers = Collections.synchronizedCollection(new LinkedList<>());
168168
private transient Map<String, Orderer> ordererEndpointMap = Collections.synchronizedMap(new HashMap<>());
169-
170169
// Name of the channel is only meaningful to the client
171170
private final String name;
172171
private transient String toString;
@@ -384,7 +383,6 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
384383
for (Orderer orderer : orderers) {
385384
ordererEndpointMap.put(orderer.getEndpoint(), orderer);
386385
}
387-
388386
}
389387

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

43924393
TransactionContext transactionContext = getTransactionContext(transactionProposalRequest.getUserContext());

0 commit comments

Comments
 (0)