You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2024/08/15 14:41:07 UTC

(lucenenet) branch master updated: Finalizer fix (#951)

This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git


The following commit(s) were added to refs/heads/master by this push:
     new 185467228 Finalizer fix (#951)
185467228 is described below

commit 185467228ec1cdbf61d86cb2c45150c95035f96a
Author: Stefan Seeland <16...@users.noreply.github.com>
AuthorDate: Thu Aug 15 16:41:01 2024 +0200

    Finalizer fix (#951)
    
    * Fixed performance / cpu resource leak  issue of IndexReader
    
    Dropped outdated sdk build dependencies
    
    * Reverted changes to get it on my machine publishing nuget packages
    
    * Fixed typo
    
    * Review findings
    
    * Update Lucene.Net.Tests.CodeAnalysis.csproj
    
    * publish-test-results-for-test-projects.yml: Updated Lucene.Net.Tests.CodeAnalysis to publish tests for net8.0
    
    * .github/workflows/Lucene-Net-Tests-CodeAnalysis.yml: Updated to test on net8.0
    
    ---------
    
    Co-authored-by: Shad Storhaug <sh...@shadstorhaug.com>
---
 .../azure-templates/publish-test-results-for-test-projects.yml |  2 +-
 .github/workflows/Lucene-Net-Tests-CodeAnalysis.yml            |  2 +-
 Lucene.Net.sln                                                 |  8 ++++----
 src/Lucene.Net/Index/IndexReader.cs                            | 10 +++-------
 src/Lucene.Net/Support/ObsoleteAPI/IndexReader.cs              |  7 +++++--
 .../Lucene.Net.Tests.CodeAnalysis.csproj                       |  8 ++------
 6 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/.build/azure-templates/publish-test-results-for-test-projects.yml b/.build/azure-templates/publish-test-results-for-test-projects.yml
index a113396c0..ec2a1237d 100644
--- a/.build/azure-templates/publish-test-results-for-test-projects.yml
+++ b/.build/azure-templates/publish-test-results-for-test-projects.yml
@@ -74,7 +74,7 @@ steps:
 - template: publish-test-results.yml
   parameters:
     testProjectName: 'Lucene.Net.Tests.CodeAnalysis'
-    framework: 'net5.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
+    framework: 'net8.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
     vsTestPlatform: '${{ parameters.vsTestPlatform }}'
     osName: '${{ parameters.osName }}'
     testResultsFormat: '${{ parameters.testResultsFormat }}'
diff --git a/.github/workflows/Lucene-Net-Tests-CodeAnalysis.yml b/.github/workflows/Lucene-Net-Tests-CodeAnalysis.yml
index 886a49b90..8a06e864d 100644
--- a/.github/workflows/Lucene-Net-Tests-CodeAnalysis.yml
+++ b/.github/workflows/Lucene-Net-Tests-CodeAnalysis.yml
@@ -49,7 +49,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [windows-latest, ubuntu-latest]
-        framework: [net5.0]
+        framework: [net8.0]
         platform: [x64]
         configuration: [Release]
         exclude:
diff --git a/Lucene.Net.sln b/Lucene.Net.sln
index 7f6fa0562..3c51015dc 100644
--- a/Lucene.Net.sln
+++ b/Lucene.Net.sln
@@ -1,5 +1,5 @@
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
+# Visual Studio Version 17
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,7 +16,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-VisualStudioVersion = 16.0.29806.167
+VisualStudioVersion = 17.10.35004.147
 MinimumVisualStudioVersion = 15.0.26730.8
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "azure-templates", "azure-templates", "{05CE3A39-40D4-452D-AFE0-E57E536A08C6}"
 	ProjectSection(SolutionItems) = preProject
@@ -41,10 +41,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{4016BD
 		build = build
 		build.bat = build.bat
 		build.ps1 = build.ps1
-		.build\runbuild.ps1 = .build\runbuild.ps1
 		.build\dependencies.props = .build\dependencies.props
 		.build\nuget.props = .build\nuget.props
 		.build\release.targets = .build\release.targets
+		.build\runbuild.ps1 = .build\runbuild.ps1
 		.build\TestReferences.Common.targets = .build\TestReferences.Common.targets
 		TestTargetFramework.props = TestTargetFramework.props
 	EndProjectSection
@@ -263,7 +263,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lucene.Net.Tests.AllProject
 EndProject
 Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "websites", "websites\", "{8988CDA4-8420-4BEE-869A-66825055EED2}"
 	ProjectSection(WebsiteProperties) = preProject
-		TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.6.2"
+		TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.8"
 		Debug.AspNetCompiler.VirtualPath = "/localhost_59352"
 		Debug.AspNetCompiler.PhysicalPath = "websites\"
 		Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_59352\"
diff --git a/src/Lucene.Net/Index/IndexReader.cs b/src/Lucene.Net/Index/IndexReader.cs
index f8fa30527..518cbde04 100644
--- a/src/Lucene.Net/Index/IndexReader.cs
+++ b/src/Lucene.Net/Index/IndexReader.cs
@@ -3,9 +3,11 @@ using Lucene.Net.Documents;
 using Lucene.Net.Support;
 using Lucene.Net.Support.Threading;
 using Lucene.Net.Util;
+
 #if !FEATURE_CONDITIONALWEAKTABLE_ENUMERATOR
 using Lucene.Net.Util.Events;
 #endif
+
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -655,12 +657,6 @@ namespace Lucene.Net.Index
                 getCacheKeysEvent.Subscribe(OnGetCacheKeys);
         }
 
-        // LUCENENET specific: Clean up the weak event handler if this class goes out of scope
-        ~IndexReader()
-        {
-            Dispose(false);
-        }
-
         // LUCENENET specific: Add weak event handler for .NET Standard 2.0 and .NET Framework, since we don't have an enumerator to use
         private void OnGetParentReaders(WeakEvents.GetParentReadersEventArgs e)
         {
@@ -781,4 +777,4 @@ namespace Lucene.Net.Index
         /// Invoked when the <see cref="IndexReader"/> is disposed. </summary>
         void OnDispose(IndexReader reader);
     }
-}
\ No newline at end of file
+}
diff --git a/src/Lucene.Net/Support/ObsoleteAPI/IndexReader.cs b/src/Lucene.Net/Support/ObsoleteAPI/IndexReader.cs
index 806fb58e6..63716cdb6 100644
--- a/src/Lucene.Net/Support/ObsoleteAPI/IndexReader.cs
+++ b/src/Lucene.Net/Support/ObsoleteAPI/IndexReader.cs
@@ -39,6 +39,7 @@ namespace Lucene.Net.Index
         private sealed class ReaderCloseListenerWrapper : IReaderDisposedListener
         {
             private readonly IReaderClosedListener listener;
+
             public ReaderCloseListenerWrapper(IReaderClosedListener listener)
             {
                 this.listener = listener ?? throw new ArgumentNullException(nameof(listener));
@@ -47,7 +48,9 @@ namespace Lucene.Net.Index
             public void OnDispose(IndexReader reader) => listener.OnClose(reader);
 
             public override bool Equals(object obj) => listener.Equals(obj);
+
             public override int GetHashCode() => listener.GetHashCode();
+
             public override string ToString() => listener.ToString();
         }
 
@@ -57,7 +60,7 @@ namespace Lucene.Net.Index
         /// <para/>
         /// @lucene.experimental
         /// </summary>
-        [Obsolete("Use AddReaderDisposedListerner method instead. This method will be removed in 4.8.0 release candidate."), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+        [Obsolete("Use AddReaderDisposedListener method instead. This method will be removed in 4.8.0 release candidate."), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
         public void AddReaderClosedListener(IReaderClosedListener listener)
         {
             EnsureOpen();
@@ -69,7 +72,7 @@ namespace Lucene.Net.Index
         /// <para/>
         /// @lucene.experimental
         /// </summary>
-        [Obsolete("Use RemoveReaderDisposedListerner method instead. This method will be removed in 4.8.0 release candidate."), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+        [Obsolete("Use RemoveReaderDisposedListener method instead. This method will be removed in 4.8.0 release candidate."), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
         public void RemoveReaderClosedListener(IReaderClosedListener listener)
         {
             EnsureOpen();
diff --git a/src/dotnet/Lucene.Net.Tests.CodeAnalysis/Lucene.Net.Tests.CodeAnalysis.csproj b/src/dotnet/Lucene.Net.Tests.CodeAnalysis/Lucene.Net.Tests.CodeAnalysis.csproj
index 768f84ad1..6c5e8e057 100644
--- a/src/dotnet/Lucene.Net.Tests.CodeAnalysis/Lucene.Net.Tests.CodeAnalysis.csproj
+++ b/src/dotnet/Lucene.Net.Tests.CodeAnalysis/Lucene.Net.Tests.CodeAnalysis.csproj
@@ -22,17 +22,13 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net8.0</TargetFramework>
     <RootNamespace>Lucene.Net.CodeAnalysis</RootNamespace>
     
     <IsPublishable>false</IsPublishable>
-    <IsPublishable Condition=" '$(TargetFramework)' == 'net5.0' ">true</IsPublishable>
+    <IsPublishable Condition=" '$(TargetFramework)' == 'net8.0' ">true</IsPublishable>
     <IsTestProject>true</IsTestProject>
-
-    <!-- We purposely test on EoL frameworks for testing netstandard2.1, but we want to keep this warning in production code. -->
-    <CheckEolTargetFramework>false</CheckEolTargetFramework>
   </PropertyGroup>
-
   
   <Import Project="$(SolutionDir).build/TestReferences.Common.targets" />