diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index e540dc0b6e2..0c38b2f135c 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -335,35 +335,33 @@ public synchronized void export() { } if (shouldDelay()) { - delayExportExecutor.schedule(this::doExport, delay, TimeUnit.MILLISECONDS); + delayExportExecutor.schedule(this::doExport, getDelay(), TimeUnit.MILLISECONDS); } else { doExport(); } } private boolean shouldExport() { - Boolean shouldExport = getExport(); - if (shouldExport == null && provider != null) { - shouldExport = provider.getExport(); - } - + Boolean export = getExport(); // default value is true - if (shouldExport == null) { - return true; - } + return export == null ? true : export; + } - return shouldExport; + @Override + public Boolean getExport() { + return (export == null && provider != null) ? provider.getExport() : export; } private boolean shouldDelay() { Integer delay = getDelay(); - if (delay == null && provider != null) { - delay = provider.getDelay(); - } - this.delay = delay; return delay != null && delay > 0; } + @Override + public Integer getDelay() { + return (delay == null && provider != null) ? provider.getDelay() : delay; + } + protected synchronized void doExport() { if (unexported) { throw new IllegalStateException("The service " + interfaceClass.getName() + " has already unexported!");