Skip to content

Commit 0b65863

Browse files
committed
Bug 37684997 - SimpleQeueryRecorder ArgumentOutOfRangeException
[git-p4: depot-paths = "//dev/main.net/": change = 114934]
1 parent a7d6abb commit 0b65863

File tree

2 files changed

+76
-4
lines changed

2 files changed

+76
-4
lines changed

src/Coherence/Util/SimpleQueryRecord.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
using System;
88
using System.Collections;
@@ -818,8 +818,8 @@ public void ParseIndexDescription(string sIndex)
818818

819819
m_sIndexDef = sIndex.Substring(0, iStart);
820820

821-
int iEnd = sIndex.IndexOf(',', iStart);
822-
m_cBytes = XmlHelper.ParseMemorySize(sIndex.Substring(iStart + FOOTPRINT_LEN, iEnd));
821+
int iLen = sIndex.IndexOf(',', iStart) - (iStart + FOOTPRINT_LEN);
822+
m_cBytes = XmlHelper.ParseMemorySize(sIndex.Substring(iStart + FOOTPRINT_LEN, iLen));
823823

824824
iStart = sIndex.IndexOf(MAP_SIZE);
825825
m_cDistinctValues = Int32.Parse(sIndex.Substring(iStart + MAP_SIZE_LEN));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl.
6+
*/
7+
using System;
8+
using System.Collections;
9+
using NUnit.Framework;
10+
using Tangosol.Net;
11+
using Tangosol.Run.Xml;
12+
using Tangosol.Util.Aggregator;
13+
using Tangosol.Util.Extractor;
14+
using Tangosol.Util.Filter;
15+
16+
namespace Tangosol.Util;
17+
18+
[TestFixture]
19+
public class SimpleQueryRecordTests
20+
{
21+
private INamedCache GetCache(String cacheName)
22+
{
23+
IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory;
24+
25+
IXmlDocument config = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-cache-config.xml");
26+
ccf.Config = config;
27+
28+
return CacheFactory.GetCache(cacheName);
29+
}
30+
31+
[SetUp]
32+
public void SetUp()
33+
{
34+
TestContext.Error.WriteLine($"[START] {DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}: {TestContext.CurrentContext.Test.FullName}");
35+
}
36+
37+
[TearDown]
38+
public void TearDown()
39+
{
40+
TestContext.Error.WriteLine($"[END] {DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}: {TestContext.CurrentContext.Test.FullName}");
41+
}
42+
43+
[Test]
44+
public void TestQueryRecorder()
45+
{
46+
INamedCache cache = GetCache("dist-query-recorder");
47+
cache.Clear();
48+
49+
var valueExtractor = new UniversalExtractor("City");
50+
try
51+
{
52+
Hashtable ht = new Hashtable();
53+
Address address1 = new Address("Street1", "City1", "State1", "Zip1");
54+
Address address2 = new Address("Street2", "City2", "State2", "Zip2");
55+
ht.Add("key1", address1);
56+
ht.Add("key2", address2);
57+
cache.InsertAll(ht);
58+
59+
cache.AddIndex(valueExtractor, false, null);
60+
61+
QueryRecorder queryRecorder = new QueryRecorder(QueryRecorder.RecordType.Explain);
62+
IFilter yourFilter = new ContainsFilter(new UniversalExtractor("City"), "City1");
63+
Object resultsExplain = cache.Aggregate(yourFilter, queryRecorder);
64+
Console.WriteLine(resultsExplain);
65+
}
66+
finally
67+
{
68+
cache.RemoveIndex(valueExtractor);
69+
CacheFactory.Shutdown();
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)