Skip to content

Commit

Permalink
fix(shared): use MBeanInfoError from jolokia.js instead of custom err…
Browse files Browse the repository at this point in the history
…or type
  • Loading branch information
tadayosi committed Jun 12, 2024
1 parent 5d47a45 commit f474031
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/hawtio/src/plugins/shared/jolokia-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('JolokiaService', () => {
expect(options.maxCollectionSize).toEqual(10000)
})

test('problematic JSON response from case hawtio/hawtio#3401', async () => {
test('problematic JSON response from case hawtio/hawtio-next#902', () => {
const response = {
value: {
'java.util.logging': {
Expand All @@ -111,6 +111,6 @@ describe('JolokiaService', () => {
},
},
}
jolokiaService.unwindListResponse(response.value)
expect(() => jolokiaService.unwindListResponse(response.value)).not.toThrow()
})
})
13 changes: 3 additions & 10 deletions packages/hawtio/src/plugins/shared/tree/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isEmpty } from '@hawtiosrc/util/objects'
import { matchWithWildcard, stringSorter, trimQuotes } from '@hawtiosrc/util/strings'
import { TreeViewDataItem } from '@patternfly/react-core'
import { CubeIcon, FolderIcon, FolderOpenIcon, LockIcon } from '@patternfly/react-icons'
import { MBeanAttribute, MBeanInfo, MBeanOperation } from 'jolokia.js'
import { MBeanAttribute, MBeanInfo, MBeanInfoError, MBeanOperation } from 'jolokia.js'
import React from 'react'
import { define, is, object, optional, record, string, type } from 'superstruct'
import { log } from './globals'
Expand All @@ -23,11 +23,8 @@ export function isJmxDomains(value: unknown): value is OptimisedJmxDomains {

export type OptimisedJmxDomain = Record<string, OptimisedMBeanInfo>

function isMBeanInfoOrError(value: unknown): boolean {
return isMBeanInfo(value) || isMBeanInfoError(value)
}

export function isJmxDomain(value: unknown): value is OptimisedJmxDomain {
const isMBeanInfoOrError = (value: unknown) => isMBeanInfo(value) || isMBeanInfoError(value)
return is(value, record(string(), define('MBeanInfo', isMBeanInfoOrError)))
}

Expand All @@ -51,11 +48,7 @@ export function isMBeanInfo(value: unknown): value is OptimisedMBeanInfo {
)
}

export interface ErrorMBeanInfo {
error: string
}

export function isMBeanInfoError(value: unknown): value is ErrorMBeanInfo {
export function isMBeanInfoError(value: unknown): value is MBeanInfoError {
return is(value, type({ error: string() }))
}

Expand Down

0 comments on commit f474031

Please sign in to comment.