Skip to content

Commit 959a295

Browse files
committed
[FAB-4072] Enable experimental Java chain code support
Undo the commit `29e0c40` that disabled the Java chaincode Use conditional go build tag `experimental` to enable Java chaincode support Change-Id: I16bb902e76c59b68ea1d47c382749c146ef33dd1 Signed-off-by: Jingxiao Gu <gujingxiao@gmail.com>
1 parent 51d4df6 commit 959a295

File tree

7 files changed

+73
-31
lines changed

7 files changed

+73
-31
lines changed

core/endorser/endorser.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,14 @@ func (e *Endorser) disableJavaCCInst(cid *pb.ChaincodeID, cis *pb.ChaincodeInvoc
208208

209209
cds := ccpack.GetDepSpec()
210210

211-
//finally, if JAVA error out
212-
if cds.ChaincodeSpec.Type == pb.ChaincodeSpec_JAVA {
213-
return errors.New("Java chaincode is work-in-progress and disabled")
211+
if javaEnabled() {
212+
endorserLogger.Debug("java chaincode enabled")
213+
} else {
214+
endorserLogger.Debug("java chaincode disabled")
215+
//finally, if JAVA not enabled error out
216+
if cds.ChaincodeSpec.Type == pb.ChaincodeSpec_JAVA {
217+
return errors.New("Java chaincode is work-in-progress and disabled")
218+
}
214219
}
215220

216221
//not a java install, instantiate or upgrade op

core/endorser/endorser_test.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
22
Copyright IBM Corp. 2016 All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package endorser
@@ -364,10 +354,10 @@ func TestJavaDeploy(t *testing.T) {
364354

365355
_, _, err := deploy(endorserServer, chainID, spec, nil)
366356
if err == nil {
367-
t.Fail()
368-
t.Logf("expected java CC deploy to fail")
369-
chaincode.GetChain().Stop(context.Background(), cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
370-
return
357+
if !javaEnabled() {
358+
t.Fail()
359+
t.Logf("expected java CC deploy to fail")
360+
}
371361
}
372362
chaincode.GetChain().Stop(context.Background(), cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
373363
}

core/endorser/java.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//+build experimental
2+
3+
/*
4+
Copyright IBM Corp. 2016 All Rights Reserved.
5+
6+
SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
package endorser
10+
11+
func javaEnabled() bool {
12+
return true
13+
}

core/endorser/nojava.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//+build !experimental
2+
3+
/*
4+
Copyright IBM Corp. 2016 All Rights Reserved.
5+
6+
SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
package endorser
10+
11+
func javaEnabled() bool {
12+
return false
13+
}

peer/chaincode/common.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
22
Copyright IBM Corp. 2016 All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package chaincode
@@ -85,8 +75,13 @@ func getChaincodeSpec(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
8575
}
8676

8777
chaincodeLang = strings.ToUpper(chaincodeLang)
88-
if pb.ChaincodeSpec_Type_value[chaincodeLang] == int32(pb.ChaincodeSpec_JAVA) {
89-
return nil, fmt.Errorf("Java chaincode is work-in-progress and disabled")
78+
if javaEnabled() {
79+
logger.Debug("java chaincode enabled")
80+
} else {
81+
logger.Debug("java chaincode disabled")
82+
if pb.ChaincodeSpec_Type_value[chaincodeLang] == int32(pb.ChaincodeSpec_JAVA) {
83+
return nil, fmt.Errorf("Java chaincode is work-in-progress and disabled")
84+
}
9085
}
9186
spec = &pb.ChaincodeSpec{
9287
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]),

peer/chaincode/java.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//+build experimental
2+
3+
/*
4+
Copyright IBM Corp. 2016 All Rights Reserved.
5+
6+
SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
package chaincode
10+
11+
func javaEnabled() bool {
12+
return true
13+
}

peer/chaincode/nojava.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//+build !experimental
2+
3+
/*
4+
Copyright IBM Corp. 2016 All Rights Reserved.
5+
6+
SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
package chaincode
10+
11+
func javaEnabled() bool {
12+
return false
13+
}

0 commit comments

Comments
 (0)