Java 9 HttpClient挂起

时间:2017-05-30 15:16:11

标签: java http2 java-9

我正在试验来自Sub Calculate_Nights_days() 'Application.ScreenUpdating = False Dim Ws As Worksheet Dim starting_ws As Worksheet Dim StartDate As Date Dim EndDate As Date Dim crng As Range Dim sValue As Date Dim sRng As Range Dim lastrow As Long Dim v As Integer Dim WsT As Worksheet Dim lastrowTotals As Long Dim WsTDateRange As Range Set WsT = Worksheets("Totals") 'Nights lastrowTotals = WsT.Cells(WsT.Rows.Count, "A").End(xlUp).Row If lastrowTotals > 1 Then WsT.Range("A2:A" & lastrowTotals).ClearContents WsT.Range("B2:B" & lastrowTotals).ClearContents WsT.Range("C2:C" & lastrowTotals).ClearContents Else End If Set starting_ws = ActiveSheet For Each Ws In Workbooks("Nights and Days").Worksheets If Ws.Name <> "Totals" Then Ws.Activate lastrow = Ws.Cells(Ws.Rows.Count, "A").End(xlUp).Row Set crng = Ws.Range("A2:A" & lastrow) EndDate = Application.Max(crng) StartDate = Application.Min(crng) For x = StartDate To EndDate v = 0 For Each y In crng If y = x And y.Offset(0, 2).Value = "Night" Then v = v + 1 End If Next y If WorksheetFunction.CountA(WsT.Range("A:A")) = 0 Then WsT.Range("A2").Value = x WsT.Range("B2").Value = v Else lastrowTotals = WsT.Cells(WsT.Rows.Count, "A").End(xlUp).Row WsT.Range("A" & lastrowTotals).Offset(1, 0).Value = x WsT.Range("A" & lastrowTotals).Offset(1, 1).Value = v End If Next x Else End If Next 'Days lastrowTotals = WsT.Cells(WsT.Rows.Count, "A").End(xlUp).Row For Each Ws In Workbooks("Nights and Days").Worksheets If Ws.Name <> "Totals" Then Ws.Activate lastrow = Ws.Cells(Ws.Rows.Count, "A").End(xlUp).Row Set crng = Ws.Range("A2:A" & lastrow) EndDate = Application.Max(crng) StartDate = Application.Min(crng) For x = StartDate To EndDate v = 0 For Each y In crng If y = x And y.Offset(0, 2).Value = "Day" Then v = v + 1 End If Next y If WorksheetFunction.CountA(WsT.Range("A:A")) = 0 Then WsT.Range("A2").Value = x WsT.Range("C2").Value = v Else lastrowTotals = WsT.Cells(WsT.Rows.Count, "A").End(xlUp).Row Set WsTDateRange = WsT.Range("A2:A" & lastrowTotals) With WsTDateRange Set z = .Find(x, LookIn:=xlValues) If Not z Is Nothing Then firstAddress = z.Address Do z.Offset(0, 2).Value = v Set z = .FindNext(z) If z Is Nothing Then GoTo DoneFinding End If Loop While z Is Nothing And z.Address <> firstAddress End If DoneFinding: End With End If Next x Else End If Next WsT.Activate Range("A2:A" & lastrowTotals).NumberFormat = "dd/mm/yyyy" Range("B2:B" & lastrowTotals).NumberFormat = "General" Range("C2:C" & lastrowTotals).NumberFormat = "General" WsT.Range("A2:C50000").CurrentRegion.Sort WsT.Range("A2"), xlAscending 'Application.ScreenUpdating = True End Sub 的{​​{1}}客户端。代码取自this example

HTTP/2

但客户端永远挂在最后一行。请告知如何解决它?

调试显示它在方法jdk 9-ea+171中无限等待。

1 个答案:

答案 0 :(得分:4)

这是最新版本的HTTP2连接实现中的错误。它不会出现以前的版本。

首先,您需要指定GET方法以避免获得空指针异常。

主要线程正在等待发送连接前言。它锁定倒计时锁定以等待本前言的接收。为了唤醒自己,任何HttpClient都会创建一个读取传入流量的辅助线程。这个线程应该唤醒主线程但有时候,这种情况永远不会发生。如果你经常运行你的例子,你会发现这有时会起作用。我想有一场阅读前言的竞赛。

不幸的是,前言的阅读也不考虑任何超时,因此除了中断主线程之外,没有办法唤醒主线程。

这是官方机票:https://bugs.openjdk.java.net/browse/JDK-8181430