<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.8-SNAPSHOT</li>
<li>Operating System version: xxx</li>
<li>Java version: xxx</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>Do not start zookeeper server, which is used as a metadata center</li>
<li>start a provider</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">The app exit normally</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">The app exit with a NPE</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Exception in thread &quot;DubboShutdownHook&quot; java.lang.RuntimeException: java.lang.NullPointerException
	at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:48)
	at org.apache.dubbo.common.lang.ShutdownHookCallbacks.lambda$callback$0(ShutdownHookCallbacks.java:70)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.apache.dubbo.common.lang.ShutdownHookCallbacks.callback(ShutdownHookCallbacks.java:70)
	at org.apache.dubbo.config.DubboShutdownHook.callback(DubboShutdownHook.java:85)
	at org.apache.dubbo.config.DubboShutdownHook.run(DubboShutdownHook.java:73)
Caused by: java.lang.NullPointerException
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportMetadataService(DubboBootstrap.java:1009)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:1188)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap$1.callback(DubboBootstrap.java:198)
	at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:46)
	... 5 more"><pre class="notranslate"><code class="notranslate">Exception in thread "DubboShutdownHook" java.lang.RuntimeException: java.lang.NullPointerException
	at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:48)
	at org.apache.dubbo.common.lang.ShutdownHookCallbacks.lambda$callback$0(ShutdownHookCallbacks.java:70)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.apache.dubbo.common.lang.ShutdownHookCallbacks.callback(ShutdownHookCallbacks.java:70)
	at org.apache.dubbo.config.DubboShutdownHook.callback(DubboShutdownHook.java:85)
	at org.apache.dubbo.config.DubboShutdownHook.run(DubboShutdownHook.java:73)
Caused by: java.lang.NullPointerException
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportMetadataService(DubboBootstrap.java:1009)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:1188)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap$1.callback(DubboBootstrap.java:198)
	at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:46)
	... 5 more
</code></pre></div>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: v2.7.3</li>
<li>Operating System version: OSX</li>
<li>Java version: javac 1.8.0_202</li>
<li>Kotlin version: 1.3.40</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<div class="highlight highlight-source-kotlin notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="data class Data(var list: MutableList&lt;CustomizeDateTime&gt; = mutableListOf()) : Serializable {}

// Get the correct result when time has no default value or is null
// CustomizeDateTime(var time: LocalTime) or CustomizeDateTime(var time: LocalTime? = null)
data class CustomizeDateTime(var time: LocalTime = LocalTime.parse(&quot;12:00:00&quot;)) : Serializable {}

private var byteArrayOutputStream: ByteArrayOutputStream? = null
private var protostuffObjectOutput: ProtostuffObjectOutput? = null
private var protostuffObjectInput: ProtostuffObjectInput? = null
private var byteArrayInputStream: ByteArrayInputStream? = null

@Throws(IOException::class)
private fun flushToInput() {
    this.protostuffObjectOutput?.flushBuffer()
    this.byteArrayInputStream = ByteArrayInputStream(byteArrayOutputStream?.toByteArray())
    this.protostuffObjectInput = ProtostuffObjectInput(byteArrayInputStream)
}

@Before
@Throws(Exception::class)
fun setUp() {
    this.byteArrayOutputStream = ByteArrayOutputStream()
    this.protostuffObjectOutput = ProtostuffObjectOutput(byteArrayOutputStream)
}

@Test
fun `Test List LocalTime`() {
    val times = mutableListOf(
            CustomizeDateTime(LocalTime.parse(&quot;08:00:00&quot;)),
            CustomizeDateTime(LocalTime.parse(&quot;12:00:00&quot;)),
            CustomizeDateTime(LocalTime.parse(&quot;19:01:10&quot;)))
    val data = Data(times)
    this.protostuffObjectOutput?.writeObject(data)
    this.flushToInput()

    val serializedTime = protostuffObjectInput?.readObject()
    println(serializedTime)
}"><pre class="notranslate"><span class="pl-k">data class</span> <span class="pl-en">Data</span>(<span class="pl-k">var</span> <span class="pl-smi">list</span><span class="pl-k">:</span> <span class="pl-en">MutableList</span>&lt;<span class="pl-en">CustomizeDateTime</span>&gt; = mutableListOf()) : Serializable {}

<span class="pl-c"><span class="pl-c">//</span> Get the correct result when time has no default value or is null</span>
<span class="pl-c"><span class="pl-c">//</span> CustomizeDateTime(var time: LocalTime) or CustomizeDateTime(var time: LocalTime? = null)</span>
<span class="pl-k">data class</span> <span class="pl-en">CustomizeDateTime</span>(<span class="pl-k">var</span> <span class="pl-smi">time</span><span class="pl-k">:</span> <span class="pl-en">LocalTime</span> = <span class="pl-en">LocalTime</span>.parse("12:00:00")) : Serializable {}

<span class="pl-k">private</span> <span class="pl-k">var</span> byteArrayOutputStream<span class="pl-k">:</span> <span class="pl-en">ByteArrayOutputStream</span><span class="pl-k">?</span> <span class="pl-k">=</span> <span class="pl-c1">null</span>
<span class="pl-k">private</span> <span class="pl-k">var</span> protostuffObjectOutput<span class="pl-k">:</span> <span class="pl-en">ProtostuffObjectOutput</span><span class="pl-k">?</span> <span class="pl-k">=</span> <span class="pl-c1">null</span>
<span class="pl-k">private</span> <span class="pl-k">var</span> protostuffObjectInput<span class="pl-k">:</span> <span class="pl-en">ProtostuffObjectInput</span><span class="pl-k">?</span> <span class="pl-k">=</span> <span class="pl-c1">null</span>
<span class="pl-k">private</span> <span class="pl-k">var</span> byteArrayInputStream<span class="pl-k">:</span> <span class="pl-en">ByteArrayInputStream</span><span class="pl-k">?</span> <span class="pl-k">=</span> <span class="pl-c1">null</span>

@Throws(<span class="pl-en">IOException</span>::<span class="pl-c1">class</span>)
<span class="pl-k">private</span> <span class="pl-k">fun</span> <span class="pl-en">flushToInput</span>() {
    <span class="pl-c1">this</span>.protostuffObjectOutput?.flushBuffer()
    <span class="pl-c1">this</span>.byteArrayInputStream <span class="pl-k">=</span> <span class="pl-en">ByteArrayInputStream</span>(byteArrayOutputStream?.toByteArray())
    <span class="pl-c1">this</span>.protostuffObjectInput <span class="pl-k">=</span> <span class="pl-en">ProtostuffObjectInput</span>(byteArrayInputStream)
}

@Before
@Throws(<span class="pl-en">Exception</span>::<span class="pl-c1">class</span>)
<span class="pl-k">fun</span> <span class="pl-en">setUp</span>() {
    <span class="pl-c1">this</span>.byteArrayOutputStream <span class="pl-k">=</span> <span class="pl-en">ByteArrayOutputStream</span>()
    <span class="pl-c1">this</span>.protostuffObjectOutput <span class="pl-k">=</span> <span class="pl-en">ProtostuffObjectOutput</span>(byteArrayOutputStream)
}

@Test
<span class="pl-k">fun</span> <span class="pl-en"><span class="pl-s">`Test List LocalTime`</span></span>() {
    <span class="pl-k">val</span> times <span class="pl-k">=</span> <span class="pl-c1">mutableListOf</span>(
            <span class="pl-en">CustomizeDateTime</span>(<span class="pl-en">LocalTime</span>.parse(<span class="pl-s"><span class="pl-pds">"</span>08:00:00<span class="pl-pds">"</span></span>)),
            <span class="pl-en">CustomizeDateTime</span>(<span class="pl-en">LocalTime</span>.parse(<span class="pl-s"><span class="pl-pds">"</span>12:00:00<span class="pl-pds">"</span></span>)),
            <span class="pl-en">CustomizeDateTime</span>(<span class="pl-en">LocalTime</span>.parse(<span class="pl-s"><span class="pl-pds">"</span>19:01:10<span class="pl-pds">"</span></span>)))
    <span class="pl-k">val</span> data <span class="pl-k">=</span> <span class="pl-en">Data</span>(times)
    <span class="pl-c1">this</span>.protostuffObjectOutput?.writeObject(data)
    <span class="pl-c1">this</span>.flushToInput()

    <span class="pl-k">val</span> serializedTime <span class="pl-k">=</span> protostuffObjectInput?.readObject()
    <span class="pl-c1">println</span>(serializedTime)
}</pre></div>
<h3 dir="auto">Expected Result</h3>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Data(list=[CustomizeDateTime(time=08:00), CustomizeDateTime(time=12:00), CustomizeDateTime(time=19:01:10)])"><pre class="notranslate"><span class="pl-en">Data</span>(<span class="pl-s1">list</span>=[<span class="pl-en">CustomizeDateTime</span>(<span class="pl-s1">time</span>=<span class="pl-c1">08</span>:<span class="pl-c1">00</span>), <span class="pl-en">CustomizeDateTime</span>(<span class="pl-s1">time</span>=<span class="pl-c1">12</span>:<span class="pl-c1">00</span>), <span class="pl-en">CustomizeDateTime</span>(<span class="pl-s1">time</span>=<span class="pl-c1">19</span>:<span class="pl-c1">01</span>:<span class="pl-c1">10</span>)])</pre></div>
<h3 dir="auto">Actual Result</h3>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Data(list=[CustomizeDateTime(time=19:01:10), CustomizeDateTime(time=19:01:10), CustomizeDateTime(time=19:01:10)])"><pre class="notranslate"><span class="pl-en">Data</span>(<span class="pl-s1">list</span>=[<span class="pl-en">CustomizeDateTime</span>(<span class="pl-s1">time</span>=<span class="pl-c1">19</span>:<span class="pl-c1">01</span>:<span class="pl-c1">10</span>), <span class="pl-en">CustomizeDateTime</span>(<span class="pl-s1">time</span>=<span class="pl-c1">19</span>:<span class="pl-c1">01</span>:<span class="pl-c1">10</span>), <span class="pl-en">CustomizeDateTime</span>(<span class="pl-s1">time</span>=<span class="pl-c1">19</span>:<span class="pl-c1">01</span>:<span class="pl-c1">10</span>)])</pre></div>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>