send-event.pl is broken after OpenNMS 25.1.0 update

Description

The Release notes for 25.1.0 note that the event XML format has had a change to the time format.

send-event.pl seems to reflect that change:

$ diff send-event.pl /tmp/orig/send-event.pl 38c38 < > 59c59 < @PARMS = map { parse_parm($_) } @PARMS; > @PARMS = reverse map { parse_parm($_) } @PARMS; 166,169c166,170 < my $month = sprintf("%02d", $mon + 1); < $mday = sprintf("%02d", $mday); < $min = sprintf("%02d", $min); < $sec = sprintf("%02d", $sec); > my $month = $mon; > $min = sprintf("%02d", $min); > $sec = sprintf("%02d", $sec); > my @week = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); > my @month = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); 190c191 < <time>${year}${month}${mday}T${hour}:${min}:${sec}+00:00</time> > <time>$week[$wday], $mday $month[$month] $year $hour:$min:$sec o'clock $ZONE</time> 266c267,268 < --service, -s service name > --timezone, -t the time zone you are in > --service, -s service name

However, when run, I'm getting the following in eventd.log:

2019-11-11 14:32:36,783 ERROR [nioEventLoopGroup-3-4] o.o.n.e.l.XmlEventProcessor: An error occurred while processing the event: Exception Description: The object [2019-11-11T4:32:36+00:00], of class [class java.lang.String], could not be converted to [class java.util.Date]. Internal Exception: java.time.format.DateTimeParseException: Text '2019-11-11T4:32:36+00:00' could not be parsed at index 11 org.eclipse.persistence.exceptions.ConversionException: Exception Description: The object [2019-11-11T4:32:36+00:00], of class [class java.lang.String], could not be converted to [class java.util.Date]. Internal Exception: java.time.format.DateTimeParseException: Text '2019-11-11T4:32:36+00:00' could not be parsed at index 11 at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:87) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.internal.jaxb.XMLJavaTypeConverter.convertDataValueToObjectValue(XMLJavaTypeConverter.java:162) ~[org.eclipse.persistence.moxy-2.5.1.jar:?] at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.convertDataValueToObjectValue(XMLDirectMapping.java:526) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getAttributeValue(XMLDirectMapping.java:296) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getAttributeValue(XMLDirectMapping.java:1) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.internal.oxm.XMLDirectMappingNodeValue.endElement(XMLDirectMappingNodeValue.java:192) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl.endElement(UnmarshalRecordImpl.java:1021) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:570) ~[?:?] at org.opennms.core.xml.SimpleNamespaceFilter.endElement(SimpleNamespaceFilter.java:95) ~[org.opennms.core.xml-25.1.0.jar:?] at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[org.apache.servicemix.bundles.xerces-2.11.0_1.jar:?] at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357) ~[?:?] at org.eclipse.persistence.internal.oxm.record.XMLReader.parse(XMLReader.java:221) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:492) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:695) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:655) ~[org.eclipse.persistence.core-2.5.1.jar:?] at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:301) ~[org.eclipse.persistence.moxy-2.5.1.jar:?] at org.opennms.core.xml.JaxbUtils.unmarshal(JaxbUtils.java:276) ~[org.opennms.core.xml-25.1.0.jar:?] at org.opennms.core.xml.JaxbUtils.unmarshal(JaxbUtils.java:209) ~[org.opennms.core.xml-25.1.0.jar:?] at org.opennms.core.xml.JaxbUtils.unmarshal(JaxbUtils.java:214) ~[org.opennms.core.xml-25.1.0.jar:?] at org.opennms.netmgt.eventd.listener.XmlEventProcessor.getEventLog(XmlEventProcessor.java:193) ~[org.opennms.features.events.daemon-25.1.0.jar:?] at org.opennms.netmgt.eventd.listener.XmlEventProcessor.channelRead(XmlEventProcessor.java:111) ~[org.opennms.features.events.daemon-25.1.0.jar:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:315) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:429) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:283) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:697) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-all-4.1.38.Final.jar:4.1.38.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.38.Final.jar:4.1.38.Final] at java.lang.Thread.run(Thread.java:834) [?:?] Caused by: java.time.format.DateTimeParseException: Text '2019-11-11T4:32:36+00:00' could not be parsed at index 11 at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2046) ~[?:?] at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1948) ~[?:?] at java.time.ZonedDateTime.parse(ZonedDateTime.java:598) ~[?:?] at java.time.ZonedDateTime.parse(ZonedDateTime.java:583) ~[?:?] at org.opennms.netmgt.events.api.EventConstants.parseToDate(EventConstants.java:1041) ~[org.opennms.features.events.api-25.1.0.jar:?] at org.opennms.netmgt.events.api.DateTimeAdapter.unmarshal(DateTimeAdapter.java:46) ~[org.opennms.features.events.api-25.1.0.jar:?] at org.opennms.netmgt.events.api.DateTimeAdapter.unmarshal(DateTimeAdapter.java:35) ~[org.opennms.features.events.api-25.1.0.jar:?] at org.eclipse.persistence.internal.jaxb.XMLJavaTypeConverter.convertDataValueToObjectValue(XMLJavaTypeConverter.java:153) ~[org.eclipse.persistence.moxy-2.5.1.jar:?] ... 53 more

 

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

John Blackburn December 8, 2019 at 10:09 PM

I can confirm that this now works.  There is now no time based failure between midnight and 10am GMT time.

Ronny Trommer November 13, 2019 at 6:01 PM

I've created a PR with your patch here: https://github.com/OpenNMS/opennms/pull/2814 and needs to be reviewed. Just comment in the PR if there is something wrong. You can drop me a direct message in Discourse with your GitHub assigned mail address so I can sign-off the PR so the contribution goes to you slightly smiling face

John Blackburn November 11, 2019 at 7:00 AM

Apologies, I tried to format the initial post, but it has not formatted the way I intended.

John Blackburn November 11, 2019 at 6:50 AM

The issue here seems to be that $hour is not padded with a 0 if it is less than 10.

adding

$hour = sprintf("%02d", $hour);

seems to fix.

My guess is that testing was done at a time when GMT was between 10:00 and 23:59

Fixed

Details

Assignee

Reporter

Components

Sprint

Affects versions

Priority

PagerDuty

Created November 11, 2019 at 6:48 AM
Updated December 8, 2019 at 10:09 PM
Resolved November 18, 2019 at 5:35 PM

Flag notifications