Skip to content

Commit

Permalink
Don't bother parsing JVM version numbers either
Browse files Browse the repository at this point in the history
  • Loading branch information
bitemyapp committed May 6, 2018
1 parent 7ba70bf commit 088ef73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/Bloodhound/Import.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Bloodhound.Import
, showText
, deleteSeveral
, oPath
, tshow
) where

import Control.Applicative as X (Alternative (..), optional)
Expand Down
18 changes: 9 additions & 9 deletions src/Database/V5/Bloodhound/Internal/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,12 +1421,17 @@ data NodeJVMInfo = NodeJVMInfo {
, nodeJVMVMVersion :: VMVersion
-- ^ JVM doesn't seme to follow normal version conventions
, nodeJVMVMName :: Text
, nodeJVMVersion :: VersionNumber
, nodeJVMVersion :: JVMVersion
, nodeJVMPID :: PID
} deriving (Eq, Show)

-- | Handles quirks in the way JVM versions are rendered (1.7.0_101 -> 1.7.0.101)
newtype JVMVersion = JVMVersion { unJVMVersion :: VersionNumber }
-- | We cannot parse JVM version numbers and we're not going to try.
newtype JVMVersion =
JVMVersion { unJVMVersion :: Text }
deriving (Eq, Show)

instance FromJSON JVMVersion where
parseJSON = withText "JVMVersion" (pure . JVMVersion)

data JVMMemoryInfo = JVMMemoryInfo {
jvmMemoryInfoDirectMax :: Bytes
Expand Down Expand Up @@ -2240,14 +2245,9 @@ instance FromJSON NodeJVMInfo where
<*> o .: "vm_vendor"
<*> o .: "vm_version"
<*> o .: "vm_name"
<*> (unJVMVersion <$> o .: "version")
<*> o .: "version"
<*> o .: "pid"

instance FromJSON JVMVersion where
parseJSON (String t) =
JVMVersion <$> parseJSON (String (T.replace "_" "." t))
parseJSON v = JVMVersion <$> parseJSON v

instance FromJSON JVMMemoryInfo where
parseJSON = withObject "JVMMemoryInfo" parse
where
Expand Down

0 comments on commit 088ef73

Please sign in to comment.