And While I’m Asking For Things

Speaking of requests, I have another quick one. My department has used the Oracle.ManagedDataAccess.dll for quite a while now in our C# (i.e., .NET) deployments, and even though we’ve had some performance issues at times, we’ve created some workarounds and eventually achieved harmony with this miscreant spawn of Oracle (who has been known to be developer-unfriendly). However, we came across a new one the other day:

Value cannot be null.
Parameter name: byteArray
Server stack trace:
at System.BitConverter.ToString(Byte[] value, Int32 startIndex, Int32 length)
at OracleInternal.TTC.TTCLob.GetLobIdString(Byte[] lobLocator)
at OracleInternal.ServiceObjects.OracleDataReaderImpl.CollectTempLOBsToBeFreed(Int32 rowNumber)
at Oracle.ManagedDataAccess.Client.OracleDataReader.ProcessAnyTempLOBs(Int32 rowNumber)
at Oracle.ManagedDataAccess.Client.OracleDataReader.Read()

Basically, if you have a null value in the CLOB column of an Oracle table, you might get this error when you attempt to access that row in the result set. After trying the most recent version of the library (as recommended by Oracle), it became obvious that they still haven’t fixed it. Strangely, the error seems to occur randomly, since it won’t always happen when running the executable against the same data. After spending some time in an effort to diagnose the error, I eventually capitulated, accepted Oracle’s foibles, and simply set all CLOB columns to EMPTY_CLOB(). Problem solved.

But for posterity and all those after me, I implore you, Oracle: can you address this simple problem in your library? I’d ask you to open-source that library, but we all know that’s not gonna happen. So, please go ahead and fix the bug for us. It’d probably take you a whole 15 minutes, the same amount of time that Ellison needs to check the rigging on one of his catamarans. We’d all appreciate it!

Advertisements

A Simple Feature Request for the Spring Community

Not long ago, I was asked by some colleagues to help troubleshoot an issue; they were having some difficulty with the production deployment of a monolith web service using Wildfly and Spring. How could I resist, considering how much I love event-driven frameworks and their ridiculously verbose log files? (You can cut the sarcasm with a knife.) In any case, it seems that the server was failing during initialization. After wading through the gazillions of lines written due to an exception from the JedisConnectionFactory, I finally found an Null exception from our code that was a clue. It seemed to indicate that a variable was missing from from our active profile. So, I looked inside the standalone.xml file to see if we were pointing to the right profile:

<server xmlns="urn:jboss:domain:1.4">

<extensions>
<!-- list of extension -->
</extensions>

<system-properties>
<property name="spring.profiles.active" value="production"/>
</system-properties>

That was the right profile name, all right…So I copied the deployed .WAR file and opened it up. Alas, the profile wasn’t inside the “/resources” directory! It seems that they weren’t deploying the right version. Problem solved.

So, that leads me to my point. Can the Spring community do me a big favor? If the target profile does not exist, then maybe the log file (among its gazillions of other lines) should say that THE TARGET PROFILE DOES NOT EXIST!

That would be a big timesaver and most appreciated.

.NET and XML: Mortal Enemies

In the past, I’ve had my issues when dealing with the compatibility between C# and XML, so much so that I’ve been inspired to write prose. At this point, I feel that it’s my duty for posterity to document the various instances where Microsoft drops the proverbial XML ball:

  1. As stated before, DTD validation of XML files (with the C# XmlReader) is broken. And when I say broken, I mean that it performs as well as a thirty-year-old VCR pulled from the ocean and then placed in a vat of hydrochloric acid. Now plug that VCR in. You’re going to get the same results.
  2. If you’re hoping to create a XSD from available XML or classes with the Visual Studio Tool (i.e., XSDT), good luck. For one, it doesn’t allow you to specify any complex rules. Also, if you’re generating a XSD schema from classes, you should know that it doesn’t work with Nullable types or any Dictionary properties, since they couldn’t budget it into their schedule.
  3. “Hey, I have a container that’s set to null. So I’ll tell C# not to mention that tag at all upon serialization, since it’s just wasted space and since I might not want that tag visible in certain cases.” It is possible…but under specific circumstances. If you plan on serializing your class as is and if you plan on not using any C# attributes on your properties, maybe. Otherwise? Nope. C# says “No soup for you!”
  4. If you want to serialize an array of strings, you get a free bonus upon serialization: all of the tags will be prefixed with a namespace (i.e., the namespace for array serialization). If you don’t want that ugly prefix, just create a wrapper container for a string array. Now do this for every literal type you can think of.
  5. Let’s say that you have a XML doc with a string that is a HTTP link. You now want to parse that XML and read that value. Of course, if that link contains a query string, all of those ampersands are already converted into instances of “&amp;“, in order to be compatible with XML standards. “But I want my data to be read incorrectly!” Well, you’re just in luck, friend! Because when you use XmlDocument.Load() to deserialize that XML, that query string will contain “amp;” and not “&amp;“, essentially turning the link into garbage. Huzzah!

These are only a few instances, but there’s more. (Don’t even get me started on deserializing payloads from a ASP.NET web service.) If anyone out there has their own experiences to add, I’d love to hear them.

Ahead of My Time

As I take more responsibility over the web services within our department, I’m trying to be more standard in its development and maintenance, including its documentation. While learning how to correctly implement Swagger pages for our services (and, yes, I know, I’m late to the party), I stumbled upon this particular wonderful little feature: interactive documentation!

A couple of years ago, I wrote a piece how documentation should be more interactive, since that would ultimately result in a more effective tool to teach people about anything (an API, a programming method, etc.). Now, since it was actually introduced years before I wrote that piece, you can say that I’m actually behind my time. I’ll accept either. Even though it’s a more basic version of the idea presented in my post, it’s still cool that there’s some work being done in that direction. Much-belated kudos to the Swagger team!