use ACCOUNT_REGISTER_CONFLICT STATE; throw UndeclaredThrowableException in the JavaContractCode.java;tags/1.1.5
@@ -1,7 +1,9 @@ | |||||
package com.jd.blockchain.contract.jvm; | package com.jd.blockchain.contract.jvm; | ||||
import java.lang.reflect.UndeclaredThrowableException; | |||||
import java.util.concurrent.Callable; | import java.util.concurrent.Callable; | ||||
import com.jd.blockchain.ledger.ContractExecuteException; | |||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
@@ -100,8 +102,12 @@ public class JavaContractCode extends AbstractContractCode { | |||||
} | } | ||||
@Override | @Override | ||||
public BytesValue call() throws Exception { | |||||
return JavaContractCode.super.processEvent(eventContext); | |||||
public BytesValue call() { | |||||
try { | |||||
return JavaContractCode.super.processEvent(eventContext); | |||||
} catch (Exception e) { | |||||
throw new UndeclaredThrowableException(new ContractExecuteException()); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -250,7 +250,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||||
} | } | ||||
long version = merkleDataset.getVersion(address); | long version = merkleDataset.getVersion(address); | ||||
if (version >= 0) { | if (version >= 0) { | ||||
throw new LedgerException("The registering account already exist!", TransactionState.DATA_ACCOUNT_EXIST); | |||||
throw new LedgerException("The registering account already exist!", TransactionState.ACCOUNT_REGISTER_CONFLICT); | |||||
} | } | ||||
if (!accessPolicy.checkRegistering(address, pubKey)) { | if (!accessPolicy.checkRegistering(address, pubKey)) { | ||||
@@ -29,11 +29,6 @@ public enum TransactionState { | |||||
*/ | */ | ||||
DATA_ACCOUNT_DOES_NOT_EXIST((byte) 0x02), | DATA_ACCOUNT_DOES_NOT_EXIST((byte) 0x02), | ||||
/** | |||||
* 数据账户存在; | |||||
*/ | |||||
DATA_ACCOUNT_EXIST((byte) 0x12), | |||||
/** | /** | ||||
* 用户不存在; | * 用户不存在; | ||||
*/ | */ | ||||
@@ -64,6 +59,11 @@ public enum TransactionState { | |||||
*/ | */ | ||||
REJECTED_BY_SECURITY_POLICY((byte) 0x10), | REJECTED_BY_SECURITY_POLICY((byte) 0x10), | ||||
/** | |||||
* 账户注册冲突; | |||||
*/ | |||||
ACCOUNT_REGISTER_CONFLICT((byte) 0x12), | |||||
/** | /** | ||||
* 由于在错误的账本上执行交易而被丢弃; | * 由于在错误的账本上执行交易而被丢弃; | ||||
*/ | */ | ||||
@@ -15,11 +15,5 @@ | |||||
<artifactId>utils-common</artifactId> | <artifactId>utils-common</artifactId> | ||||
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>com.jd.blockchain</groupId> | |||||
<artifactId>ledger-model</artifactId> | |||||
<version>${project.version}</version> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
</project> | </project> |
@@ -1,12 +1,12 @@ | |||||
package com.jd.blockchain.runtime; | package com.jd.blockchain.runtime; | ||||
import java.io.InputStream; | |||||
import java.util.concurrent.Callable; | |||||
import com.jd.blockchain.ledger.ContractExecuteException; | |||||
import com.jd.blockchain.utils.concurrent.AsyncFuture; | import com.jd.blockchain.utils.concurrent.AsyncFuture; | ||||
import com.jd.blockchain.utils.concurrent.CompletableAsyncFuture; | import com.jd.blockchain.utils.concurrent.CompletableAsyncFuture; | ||||
import java.io.InputStream; | |||||
import java.lang.reflect.UndeclaredThrowableException; | |||||
import java.util.concurrent.Callable; | |||||
public abstract class AbstractModule implements Module { | public abstract class AbstractModule implements Module { | ||||
@@ -93,8 +93,17 @@ public abstract class AbstractModule implements Module { | |||||
} | } | ||||
try { | try { | ||||
return callable.call(); | return callable.call(); | ||||
} catch (UndeclaredThrowableException e) { | |||||
if(e.getCause() == null){ | |||||
throw e; | |||||
} | |||||
if(e.getCause() instanceof RuntimeException){ | |||||
throw (RuntimeException)e.getCause(); | |||||
} | |||||
throw new IllegalStateException(e.getCause().getMessage(), e.getCause()); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new ContractExecuteException(e.getMessage(), e); | |||||
throw new IllegalStateException(e.getMessage(), e); | |||||
} finally { | } finally { | ||||
if (origClassLoader != Thread.currentThread().getContextClassLoader()) { | if (origClassLoader != Thread.currentThread().getContextClassLoader()) { | ||||
Thread.currentThread().setContextClassLoader(origClassLoader); | Thread.currentThread().setContextClassLoader(origClassLoader); | ||||
@@ -272,9 +272,9 @@ public class LedgerInitializeWebController implements LedgerInitProcess, LedgerI | |||||
do { | do { | ||||
allPermitted = startRequestPermissions(currentId, privKey); | allPermitted = startRequestPermissions(currentId, privKey); | ||||
if (!allPermitted) { | if (!allPermitted) { | ||||
if (retry < 181) { | |||||
if (retry < 601) { | |||||
try { | try { | ||||
Thread.sleep(10000); | |||||
Thread.sleep(3000); | |||||
} catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
// ignore interrupted exception; | // ignore interrupted exception; | ||||
} | } | ||||