Skip to content

Commit 27b7771

Browse files
committed
⚗️ suppress ObjectDisposedException when disposing redis connecting in startup connection tester
1 parent 9ff602d commit 27b7771

File tree

4 files changed

+122
-103
lines changed

4 files changed

+122
-103
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ indent_size = 2
1010
[*.js]
1111
indent_size = 2
1212

13+
[*.ts]
14+
indent_size = 2
15+
1316
[*.csproj]
1417
indent_size = 4
1518

local-tasks/update-tempdb-runner-files.js

-101
This file was deleted.
+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/// <reference path="../node_modules/zarro/types.d.ts" />
2+
(function () {
3+
const path = require("path"),
4+
gulp = requireModule<Gulp>("gulp"),
5+
{
6+
lsSync,
7+
FsEntities
8+
} = require("yafs"),
9+
throwIfNoFiles = requireModule<ThrowIfNoFiles>("throw-if-no-files"),
10+
opts = {
11+
parserOptions: {},
12+
builderOptions: {
13+
headless: true,
14+
renderOpts: {
15+
pretty: true
16+
}
17+
}
18+
},
19+
editXml = require("gulp-edit-xml");
20+
21+
gulp.task(
22+
"update-tempdb-runner-files",
23+
"Updates the files section of PeanutButter.TempDb.Runner/Package.nuspec to include all Release binaries",
24+
() => {
25+
const project = "source/TempDb/PeanutButter.TempDb.Runner",
26+
nuspec = `${ project }/Package.nuspec`;
27+
return gulp
28+
.src(nuspec)
29+
.pipe(throwIfNoFiles(`Nuspec not found at: ${ nuspec }`))
30+
.pipe(
31+
editXml(xml => {
32+
const releaseFolder = `${ project }/bin/Release`,
33+
projectFullPath = path.resolve(project),
34+
files = lsSync(
35+
releaseFolder,
36+
{
37+
recurse: true,
38+
entities: FsEntities.files,
39+
fullPaths: true
40+
}
41+
)
42+
.map(p => p.replace(projectFullPath, ""))
43+
.map(p => p.replace(/^\\/, ""));
44+
if (files.filter(p => p.match(/\.dll$/)).length === 0) {
45+
throw new Error(`No assemblies found under ${ releaseFolder }`);
46+
}
47+
48+
xml.package.files = [ { file: [] } ];
49+
const fileNode = xml.package.files[0].file;
50+
fileNode.push({
51+
$: {
52+
src: "icon.png",
53+
target: ""
54+
}
55+
})
56+
files
57+
.filter(filterTempDbRunnerFile)
58+
.forEach(relPath => {
59+
fileNode.push({
60+
$: {
61+
src: relPath,
62+
target: targetFor(relPath)
63+
}
64+
});
65+
});
66+
67+
return xml;
68+
}, opts)
69+
)
70+
.pipe(gulp.dest(project));
71+
}
72+
);
73+
74+
function filterTempDbRunnerFile(filepath) {
75+
if ((filepath || "").match(/netcoreapp.*\\PeanutButter.TempDb.Runner.exe$/)) {
76+
console.log(`-- ignoring: ${ filepath }`);
77+
return false;
78+
}
79+
return true;
80+
}
81+
82+
function targetFor(relPath) {
83+
let next = false;
84+
const parts = relPath.split(path.sep),
85+
targetFramework = parts.reduce((acc, cur) => {
86+
if (cur === "Release") {
87+
next = true;
88+
return acc;
89+
}
90+
if (next) {
91+
next = false;
92+
return cur;
93+
} else {
94+
return acc;
95+
}
96+
}, null);
97+
if (!targetFramework) {
98+
console.log({
99+
parts
100+
});
101+
throw new Error(
102+
`Can't determine target framework for path: ${ relPath } (should be after 'Release')`
103+
);
104+
}
105+
const
106+
pathParts = relPath.split(/[\/|\\]/),
107+
start = pathParts.indexOf("Release") + 2,
108+
subPath = pathParts.slice(start).join("/"),
109+
subFolder = path.dirname(subPath);
110+
return subFolder === "."
111+
? `lib/${ targetFramework }`
112+
: `lib/${ targetFramework }/${ subFolder }`;
113+
}
114+
})();

source/TempDb/PeanutButter.TempRedis/TempRedis.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ private void TestServerIsUp()
355355
EndPoints =
356356
{
357357
{
358-
"127.0.0.1",
359-
Port
358+
"127.0.0.1", Port
360359
}
361360
},
362361
ConnectTimeout = 50,
@@ -384,6 +383,10 @@ private void TestServerIsUp()
384383
"
385384
);
386385
}
386+
catch (ObjectDisposedException)
387+
{
388+
// suppress - perhaps a bug in StackExchange.Redis?
389+
}
387390
}
388391

389392
private void WatchServerProcess()

0 commit comments

Comments
 (0)